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:
Scott Olsen 2021-10-25 03:53:08 -04:00 committed by GitHub
parent 0682f1a61e
commit c471fcce89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -530,7 +530,8 @@ toC toCMode (Binder meta root) = emitterSrc (execState (visit startingIndent roo
var <- visit indent value
let Just t = ty
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
-- Ref
[XObj Ref _ _, value] ->