From fc5a10c3998516bb81f89e93550835eff02d0dee Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sat, 18 Nov 2023 19:44:44 -0300 Subject: [PATCH] TL_DEBUG: preserve nodekind changed by compat code Type-checker may modify the tree during traversal. Preserve the original node type name when printing the nested output when using TL_DEBUG. --- tl.lua | 8 ++++---- tl.tl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tl.lua b/tl.lua index 20e41c077..f03bd778d 100644 --- a/tl.lua +++ b/tl.lua @@ -3619,6 +3619,7 @@ local function recurse_node(root, recurse = function(ast) local xs = {} local kind = assert(ast.kind) + local kprint local cbs = visit_node.cbs local cbkind = cbs and cbs[kind] @@ -3632,8 +3633,8 @@ local function recurse_node(root, if ast.y > TL_DEBUG_MAXLINE then error("Halting execution at input line " .. ast.y) end - local k = kind == "op" and "op " .. ast.op.op or kind - tl_debug_indent_push("{{{", ast.y, ast.x, "[%s]", k) + kprint = kind == "op" and "op " .. ast.op.op or kind + tl_debug_indent_push("{{{", ast.y, ast.x, "[%s]", kprint) end local fn = walkers[kind] @@ -3653,8 +3654,7 @@ local function recurse_node(root, end if TL_DEBUG then - local k = kind == "op" and "op " .. ast.op.op or kind - tl_debug_indent_pop("}}}", "***", ast.y, ast.x, "[%s] = %s", k, ast.type and show_type(ast.type)) + tl_debug_indent_pop("}}}", "***", ast.y, ast.x, "[%s] = %s", kprint, ast.type and show_type(ast.type)) end return ret diff --git a/tl.tl b/tl.tl index 7b0ba54c1..5dabe4476 100644 --- a/tl.tl +++ b/tl.tl @@ -3619,6 +3619,7 @@ local function recurse_node(root: Node, recurse = function(ast: Node): T local xs: {T} = {} local kind = assert(ast.kind) + local kprint: string local cbs = visit_node.cbs local cbkind = cbs and cbs[kind] @@ -3632,8 +3633,8 @@ local function recurse_node(root: Node, if ast.y > TL_DEBUG_MAXLINE then error("Halting execution at input line " .. ast.y) end - local k = kind == "op" and "op " .. ast.op.op or kind - tl_debug_indent_push("{{{", ast.y, ast.x, "[%s]", k) + kprint = kind == "op" and "op " .. ast.op.op or kind + tl_debug_indent_push("{{{", ast.y, ast.x, "[%s]", kprint) end local fn = walkers[kind] @@ -3653,8 +3654,7 @@ local function recurse_node(root: Node, end if TL_DEBUG then - local k = kind == "op" and "op " .. ast.op.op or kind - tl_debug_indent_pop("}}}", "***", ast.y, ast.x, "[%s] = %s", k, ast.type and show_type(ast.type)) + tl_debug_indent_pop("}}}", "***", ast.y, ast.x, "[%s] = %s", kprint, ast.type and show_type(ast.type)) end return ret