diff options
| author | mryouse | 2022-05-12 02:50:10 +0000 | 
|---|---|---|
| committer | mryouse | 2022-05-12 02:50:10 +0000 | 
| commit | 6e83ec4e8c5315712744d98b5e89d85c45ecef40 (patch) | |
| tree | 829ed11685984999f3d28e85155303185e798272 /std.py | |
| parent | 3511e21a3e9b5117fd61b2f7cafee05c1cc1a945 (diff) | |
if returns literals
Diffstat (limited to 'std.py')
| -rw-r--r-- | std.py | 12 | 
1 files changed, 9 insertions, 3 deletions
| @@ -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 | 
