From 6e83ec4e8c5315712744d98b5e89d85c45ecef40 Mon Sep 17 00:00:00 2001 From: mryouse Date: Thu, 12 May 2022 02:50:10 +0000 Subject: if returns literals --- std.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'std.py') 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 -- cgit v1.2.3