From 062c6a3afd3b714f524ab22ef871f2eceba57438 Mon Sep 17 00:00:00 2001 From: Andrian Nord Date: Sun, 26 Jan 2014 01:30:45 +0400 Subject: [PATCH] unwarper: Fix slot elimination stack overflow on a cycled AST --- ljd/ast/unwarper.py | 8 ++++++-- test/expression.lua | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ljd/ast/unwarper.py b/ljd/ast/unwarper.py index 0758ca5..6dc679b 100644 --- a/ljd/ast/unwarper.py +++ b/ljd/ast/unwarper.py @@ -219,15 +219,19 @@ def _unwarp_expressions_pack(blocks, pack): replacements[start] = end slotworks.eliminate_temporary(end) + + _set_flow_to(start, end) else: blocks = blocks[:start_index + 1] + blocks[end_index:] start.contents = statements[:split_i] end.contents = statements[split_i:] - slotworks.eliminate_temporary(start) + # We need to kill the start's warp before slot + # elimination or it could result in a cycled AST. + _set_flow_to(start, end) - _set_flow_to(start, end) + slotworks.eliminate_temporary(start) return blocks diff --git a/test/expression.lua b/test/expression.lua index 24cdd22..0d508da 100644 --- a/test/expression.lua +++ b/test/expression.lua @@ -253,5 +253,7 @@ local function foo() } end +menu.logbook = foo(x or y) or {} + --[[ --]]