fix: Phase 3 — #25,28,29,41 token/AST/parser cleanup
Files modified (4): compiler/token/token.go — #25: Replace hand-rolled itoa with strconv.Itoa Fixes math.MinInt overflow bug in original implementation compiler/ast/ast.go — #29: Fix VarDecl.End() returning last var position Was returning Pos() (useless span info) compiler/parser/stmtreg.go — #28: Eliminate all 7 token array mutations rewriteAsIdent() modifies p.current only, not the token array Prevents backtracking corruption and improves safety compiler/lexer/lexer.go — Already clean from Phase 2 Issues resolved: #25 (MEDIUM), #28 (MEDIUM), #29 (MEDIUM), #41 partial (LOW) Total fixed: 29/53 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -117,7 +117,12 @@ type VarDecl struct {
|
||||
}
|
||||
|
||||
func (d *VarDecl) Pos() token.Position { return d.DeclPos }
|
||||
func (d *VarDecl) End() token.Position { return d.DeclPos }
|
||||
func (d *VarDecl) End() token.Position {
|
||||
if len(d.Vars) > 0 {
|
||||
return d.Vars[len(d.Vars)-1].NamePos
|
||||
}
|
||||
return d.DeclPos
|
||||
}
|
||||
func (d *VarDecl) declNode() {}
|
||||
func (d *VarDecl) stmtNode() {} // PRIVATE/PUBLIC can appear as statements
|
||||
|
||||
|
||||
Reference in New Issue
Block a user