From bb3bb065d57546370451dd9579cbad2f08758108 Mon Sep 17 00:00:00 2001 From: mryouse Date: Fri, 13 May 2022 03:47:35 +0000 Subject: bugfix: Expressions are automatically evaluated (this is a type problem) --- std.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'std.py') diff --git a/std.py b/std.py index 1476824..1bb20d4 100644 --- a/std.py +++ b/std.py @@ -77,7 +77,7 @@ def std_if(cond, t_branch, f_branch=None): else: return t_branch elif f_branch is not None: - if isinstance(t_branch, NebExpression): + if isinstance(f_branch, NebExpression): return evaluate_expression(f_branch) else: return f_branch @@ -186,9 +186,21 @@ def build_std(): STD["concat"] = [concat_string_string] # flow control + #if_bool_any_any = FuncImpl(NebFunction("if", [NebBool, NebAny, NebAny], NebAny), std_if) + #if_bool_any = FuncImpl(NebFunction("if", [NebBool, NebAny], NebAny), std_if) + if_bool_expr_expr = FuncImpl(NebFunction("if", [NebBool, NebExpression, NebExpression], NebAny), std_if) + if_bool_expr_any = FuncImpl(NebFunction("if", [NebBool, NebExpression, NebAny], NebAny), std_if) + if_bool_any_expr = FuncImpl(NebFunction("if", [NebBool, NebAny, NebExpression], NebAny), std_if) if_bool_any_any = FuncImpl(NebFunction("if", [NebBool, NebAny, NebAny], NebAny), std_if) + if_bool_expr = FuncImpl(NebFunction("if", [NebBool, NebExpression], NebAny), std_if) if_bool_any = FuncImpl(NebFunction("if", [NebBool, NebAny], NebAny), std_if) - STD["if"] = [if_bool_any_any, if_bool_any] + STD["if"] = [ + if_bool_expr_expr, + if_bool_expr_any, + if_bool_any_expr, + if_bool_any_any, + if_bool_expr, + if_bool_any] # type checking is_string = FuncImpl(NebFunction("string?", [NebAny], NebBool), std_is_string) -- cgit v1.2.3