aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormryouse2022-05-12 02:50:10 +0000
committermryouse2022-05-12 02:50:10 +0000
commit6e83ec4e8c5315712744d98b5e89d85c45ecef40 (patch)
tree829ed11685984999f3d28e85155303185e798272
parent3511e21a3e9b5117fd61b2f7cafee05c1cc1a945 (diff)
if returns literals
-rw-r--r--std.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/std.py b/std.py
index 73af405..0b39d44 100644
--- a/std.py
+++ b/std.py
@@ -61,9 +61,15 @@ def std_concat(arg1, arg2):
# flow control
def std_if(cond, t_branch, f_branch):
if cond.value:
- ret = evaluate_expression(t_branch)
+ if isinstance(t_branch, NebExpression):
+ ret = evaluate_expression(t_branch)
+ else:
+ ret = t_branch
else:
- ret = evaluate_expression(f_branch)
+ if isinstance(t_branch, NebExpression):
+ ret = evaluate_expression(f_branch)
+ else:
+ ret = f_branch
return ret
# type validation
@@ -153,7 +159,7 @@ def build_std():
STD["concat"] = [concat_string_string]
# flow control
- if_bool_expr_expr = FuncImpl(NebFunction("if", [NebBool, NebExpression, NebExpression], NebAny), std_if)
+ if_bool_expr_expr = FuncImpl(NebFunction("if", [NebBool, NebAny, NebAny], NebAny), std_if)
STD["if"] = [if_bool_expr_expr]
# type checking