aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2022-01-27 15:37:54 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:24:49 +0000
commit17cd0f83993c4d6f1b14a849b1a12de2cf8f7f60 (patch)
treea330146b53077ba2b24136c813e4d953b5bcd08d
parenttest if and when builtins (diff)
downloadalive-17cd0f83993c4d6f1b14a849b1a12de2cf8f7f60.tar.gz
alive-17cd0f83993c4d6f1b14a849b1a12de2cf8f7f60.zip
fix do, if, when
-rw-r--r--alv/builtins.moon9
1 files changed, 4 insertions, 5 deletions
diff --git a/alv/builtins.moon b/alv/builtins.moon
index c5f68a2..bf3c95f 100644
--- a/alv/builtins.moon
+++ b/alv/builtins.moon
@@ -252,8 +252,6 @@ Evaluate `expr1`, `expr2`, … and return the value of the last expression."
scope = Scope scope
children = [expr\eval scope for expr in *tail]
result = if last = children[#children] then last.result
- if result and result.metatype == '='
- result = result.type\mk_sig result\unwrap!
super RTNode :children, :result
@@ -279,9 +277,9 @@ to `then-expr`, otherwise it is equivalent to `else-xpr` if given, or nil otherw
msg = "'if'-expression needs to be constant, did you mean 'switch'?"
error Error 'argument', msg
xif = xif.result\unwrap!
- @state = xif
+ @state = xif != nil and xif != false and xif != 0
- super if xif
+ super if @state
xthen\eval scope
elseif xelse
xelse\eval scope
@@ -309,8 +307,9 @@ to `(do then-exprs…)`, otherwise it results in nil."
msg = "'when'-expression needs to be constant, did you mean 'switch'?"
error Error 'argument', msg
xif = xif.result\unwrap!
+ @state = xif != nil and xif != false and xif != 0
- super if xif
+ super if @state
scope = Scope scope
children = [expr\eval scope for expr in *tail[2,]]
result = if last = children[#children] then last.result