Skip to content

Commit

Permalink
TL_DEBUG: preserve nodekind changed by compat code
Browse files Browse the repository at this point in the history
Type-checker may modify the tree during traversal. Preserve the
original node type name when printing the nested output when using
TL_DEBUG.
  • Loading branch information
hishamhm committed Nov 19, 2023
1 parent 2fc72bf commit fc5a10c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -3619,6 +3619,7 @@ local function recurse_node<T>(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]
Expand All @@ -3632,8 +3633,8 @@ local function recurse_node<T>(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]
Expand All @@ -3653,8 +3654,7 @@ local function recurse_node<T>(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
Expand Down

0 comments on commit fc5a10c

Please sign in to comment.