diff options
author | Tom Smeding <tom@tomsmeding.com> | 2025-03-04 23:19:03 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2025-03-04 23:19:03 +0100 |
commit | 85423bf4d209f3d725d3b3fe53f5cd4054a13fe3 (patch) | |
tree | 91c9dce6859959b914307bdccfcfebc7fe659174 | |
parent | 138d1a5488638431595028bfec645008a5d5e0bb (diff) |
Compile: Fix EError
-rw-r--r-- | src/Compile.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Compile.hs b/src/Compile.hs index 1355841..53269d6 100644 --- a/src/Compile.hs +++ b/src/Compile.hs @@ -749,10 +749,13 @@ compile' env = \case -- EAccum _ n a b e -> error "TODO" -- EAccum n (compile' a) (compile' b) (compile' e) EError _ t s -> do - name <- emitStruct t -- using 'show' here is wrong, but it's good enough for me. emit $ SVerbatim $ "fprintf(stderr, \"ERROR: %s\\n\", " ++ show s ++ "); exit(1);" - return $ CEStruct name [] + case t of + STScal _ -> return (CELit "0") + _ -> do + name <- emitStruct t + return $ CEStruct name [] EZero{} -> error "Compile: monoid operations should have been eliminated" EPlus{} -> error "Compile: monoid operations should have been eliminated" |