mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-17 16:38:14 +03:00
fix: elide void definitions (#1305)
This commit is contained in:
parent
ae2186f4b7
commit
74d7d5767b
@ -307,7 +307,7 @@ toC toCMode (Binder meta root) = emitterSrc (execState (visit startingIndent roo
|
|||||||
appendToSrc (addIndent indent ++ "{\n")
|
appendToSrc (addIndent indent ++ "{\n")
|
||||||
let innerIndent = indent + indentAmount
|
let innerIndent = indent + indentAmount
|
||||||
ret <- visit innerIndent expr
|
ret <- visit innerIndent expr
|
||||||
appendToSrc (addIndent innerIndent ++ pathToC path ++ " = " ++ ret ++ ";\n")
|
when (ret /= "") $ appendToSrc (addIndent innerIndent ++ pathToC path ++ " = " ++ ret ++ ";\n")
|
||||||
delete innerIndent info
|
delete innerIndent info
|
||||||
appendToSrc (addIndent indent ++ "}\n")
|
appendToSrc (addIndent indent ++ "}\n")
|
||||||
pure ""
|
pure ""
|
||||||
@ -895,7 +895,9 @@ toDeclaration (Binder meta xobj@(XObj (Lst xobjs) _ ty)) =
|
|||||||
in defnToDeclaration meta path argList retTy ++ ";\n"
|
in defnToDeclaration meta path argList retTy ++ ";\n"
|
||||||
[XObj Def _ _, XObj (Sym path _) _ _, _] ->
|
[XObj Def _ _, XObj (Sym path _) _ _, _] ->
|
||||||
let Just t = ty
|
let Just t = ty
|
||||||
in "" ++ tyToCLambdaFix t ++ " " ++ pathToC path ++ ";\n"
|
in if (isUnit t)
|
||||||
|
then ""
|
||||||
|
else tyToCLambdaFix t ++ " " ++ pathToC path ++ ";\n"
|
||||||
XObj (Deftype t) _ _ : XObj (Sym path _) _ _ : rest ->
|
XObj (Deftype t) _ _ : XObj (Sym path _) _ _ : rest ->
|
||||||
defStructToDeclaration t path rest
|
defStructToDeclaration t path rest
|
||||||
XObj (DefSumtype t) _ _ : XObj (Sym _ _) _ _ : rest ->
|
XObj (DefSumtype t) _ _ : XObj (Sym _ _) _ _ : rest ->
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
(load "Test.carp")
|
(load "Test.carp")
|
||||||
(load "Vector.carp")
|
(load "Vector.carp")
|
||||||
|
|
||||||
|
; void definitions should get elided (issue #1296)
|
||||||
|
(def is-void ())
|
||||||
|
|
||||||
; this is a test-only module to test module resolution (see #288)
|
; this is a test-only module to test module resolution (see #288)
|
||||||
(defmodule Foo
|
(defmodule Foo
|
||||||
(register init (Fn [] Int) "fooInit")
|
(register init (Fn [] Int) "fooInit")
|
||||||
|
Loading…
Reference in New Issue
Block a user