Skip to content

Commit

Permalink
Fix a bug in monadic tuple bindings I introduced by
Browse files Browse the repository at this point in the history
misunderstaning the type annotation on StmtBind.
  • Loading branch information
robdockins committed Apr 22, 2022
1 parent 9ed30cd commit 03045b8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/SAWScript/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ bindPatternLocal pat ms v env =
Nothing -> repeat Nothing
Just (SS.Forall ks (SS.TyCon (SS.TupleCon _) ts))
-> [ Just (SS.Forall ks t) | t <- ts ]
_ -> error "bindPattern: expected tuple value"
_ -> error "bindPattern: expected tuple value"
Just t -> error ("bindPatternLocal: expected tuple type " ++ show t)
_ -> error "bindPatternLocal: expected tuple value"
SS.LPattern _ pat' -> bindPatternLocal pat' ms v env

bindPatternEnv :: SS.Pattern -> Maybe SS.Schema -> Value -> TopLevelRW -> TopLevel TopLevelRW
Expand All @@ -139,8 +139,8 @@ bindPatternEnv pat ms v env =
Nothing -> repeat Nothing
Just (SS.Forall ks (SS.TyCon (SS.TupleCon _) ts))
-> [ Just (SS.Forall ks t) | t <- ts ]
_ -> error "bindPattern: expected tuple value"
_ -> error "bindPattern: expected tuple value"
Just t -> error ("bindPatternEnv: expected tuple type " ++ show t)
_ -> error "bindPatternEnv: expected tuple value"
SS.LPattern _ pat' -> bindPatternEnv pat' ms v env

-- Interpretation of SAWScript -------------------------------------------------
Expand Down Expand Up @@ -238,10 +238,10 @@ interpretStmts stmts =
case stmts of
[] -> fail "empty block"
[SS.StmtBind _ (SS.PWild _) _ e] -> interpret e
SS.StmtBind pos pat mt e : ss ->
SS.StmtBind pos pat _mcxt e : ss ->
do env <- getLocalEnv
v1 <- interpret e
let f v = withLocalEnv (bindPatternLocal pat (SS.tMono <$> mt) v env) (interpretStmts ss)
let f v = withLocalEnv (bindPatternLocal pat Nothing v env) (interpretStmts ss)
bindValue pos v1 (VLambda f)
SS.StmtLet _ bs : ss -> interpret (SS.Let bs (SS.Block ss))
SS.StmtCode _ s : ss ->
Expand Down

0 comments on commit 03045b8

Please sign in to comment.