mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-17 16:38:14 +03:00
fix: don't emit Unit type the casts (#1349)
Previously, the forms cast to the type Unit would still result in variable assignment emissions, which produces invalid C. Consider the case: ```clojure ;; type of System.exit is (Int -> a) (defn main [] (the () (System.exit 0))) ``` This previously produced bad variable assignments. It now works as expected and emits only the function call.
This commit is contained in:
parent
0682f1a61e
commit
c471fcce89
@ -530,7 +530,8 @@ toC toCMode (Binder meta root) = emitterSrc (execState (visit startingIndent roo
|
|||||||
var <- visit indent value
|
var <- visit indent value
|
||||||
let Just t = ty
|
let Just t = ty
|
||||||
fresh = mangle (freshVar info)
|
fresh = mangle (freshVar info)
|
||||||
appendToSrc (addIndent indent ++ tyToCLambdaFix t ++ " " ++ fresh ++ " = " ++ var ++ "; // From the 'the' function.\n")
|
unless (isUnit t)
|
||||||
|
(appendToSrc (addIndent indent ++ tyToCLambdaFix t ++ " " ++ fresh ++ " = " ++ var ++ "; // From the 'the' function.\n"))
|
||||||
pure fresh
|
pure fresh
|
||||||
-- Ref
|
-- Ref
|
||||||
[XObj Ref _ _, value] ->
|
[XObj Ref _ _, value] ->
|
||||||
|
Loading…
Reference in New Issue
Block a user