Skip to content

Commit

Permalink
openEventFrames: Replace tail with pattern-matching + panic
Browse files Browse the repository at this point in the history
We have managed to call `tail` here on empty lists before (see #1000), which
leads to confusing error messages. Let's replace this with explicit
pattern-matching plus a call to `panic` in the empty list case to make it more
obvious where the error comes from. Moreover, doing this fixes a `-Wx-partial`
warning on GHC 9.8, which is also nice.
  • Loading branch information
RyanGlScott committed Aug 1, 2024
1 parent 5b217e6 commit 18ffb7f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crucible/src/Lang/Crucible/Simulator/Profiling.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import What4.SatResult

import Lang.Crucible.Backend
import Lang.Crucible.CFG.Core
import Lang.Crucible.Panic
import Lang.Crucible.Simulator.CallFrame
import Lang.Crucible.Simulator.EvalStmt
import Lang.Crucible.Simulator.ExecutionTree
Expand Down Expand Up @@ -290,7 +291,11 @@ openEventFrames = go []
go xs (e Seq.:<| es) =
case cgEvent_type e of
ENTER -> go (e:xs) es
EXIT -> go (tail xs) es
EXIT -> case xs of
(_:xss) -> go xss es
_ -> panic
"openEventFrames"
["Encountered an EXIT without a preceding ENTER"]
_ -> go xs es

openToCloseEvent :: UTCTime -> Metrics Identity -> CGEvent -> CGEvent
Expand Down

0 comments on commit 18ffb7f

Please sign in to comment.