From 29a466daff791426a7f073fa178006bf209ff584 Mon Sep 17 00:00:00 2001 From: s-ol Date: Wed, 15 Jul 2020 12:14:51 +0200 Subject: =?UTF-8?q?fix=20crash=20when=20last=20expression=20in=20(do=20?= =?UTF-8?q?=E2=80=A6)=20returns=20Constant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alv/builtins.moon | 7 +++++-- alv/rtnode.moon | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/alv/builtins.moon b/alv/builtins.moon index d5d729c..11c073d 100644 --- a/alv/builtins.moon +++ b/alv/builtins.moon @@ -251,8 +251,11 @@ Evaluate `expr1`, `expr2`, … and return the value of the last expression." eval: (scope, tail) => scope = Scope scope children = [expr\eval scope for expr in *tail] - last = children[#children] - super RTNode :children, result: last and last.result + result = if last = children[#children] then last.result + if result and result.metatype == '=' + result = result.type\mk_sig result\unwrap! + + super RTNode :children, result if_ = Constant.meta meta: diff --git a/alv/rtnode.moon b/alv/rtnode.moon index 0639e3e..98c230e 100644 --- a/alv/rtnode.moon +++ b/alv/rtnode.moon @@ -129,7 +129,7 @@ class RTNode if @result if next @side_inputs - assert @result.metatype != '=', "Const result has side_inputs" + assert @result.metatype != '=', "Const result #{@result} has side_inputs" elseif @result.metatype == '~' @result = @result.type\mk_const @result\unwrap! -- cgit v1.2.3