Skip to content

Commit ce7393e

Browse files
authored
[FRONTEND] Attach lineno information to AugAssign nodes (triton-lang#8703)
visit_AugAssign works by creating fake AST nodes for the binary operation and the assignment and visiting those. Prior to this commit, the nodes lack the correct lineno and col_offset so any errors raised here don't include the helpful '^' pointer to the offending line of code; this makes debugging painful.
1 parent ac0d9b0 commit ce7393e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

python/triton/compiler/code_generator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,11 @@ def visit_AugAssign(self, node):
703703
lhs.ctx = ast.Load()
704704
rhs = ast.BinOp(lhs, node.op, node.value)
705705
assign = ast.Assign(targets=[node.target], value=rhs)
706+
for x in ['lineno', 'col_offset', 'end_lineno', 'end_col_offset']:
707+
if hasattr(node, x):
708+
y = getattr(node, x)
709+
setattr(rhs, x, y)
710+
setattr(assign, x, y)
706711
self.visit(assign)
707712
return self.visit(lhs)
708713

0 commit comments

Comments
 (0)