From c4e1b3d3aa53d293307ddca6affff3715f3578c7 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 24 May 2026 18:24:07 +0300 Subject: fix(rpn): consolidate extractVarName into rpn_parse.go (task 6k) --- internal/rpn/operations_variables.go | 14 -------------- internal/rpn/rpn_parse.go | 13 +++++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/internal/rpn/operations_variables.go b/internal/rpn/operations_variables.go index 9f60133..d1b07eb 100644 --- a/internal/rpn/operations_variables.go +++ b/internal/rpn/operations_variables.go @@ -97,20 +97,6 @@ func (o *Operations) ClearVariables() { o.vars.ClearVariables() } -// extractVarName extracts a variable name from a StackValue. -// Symbols use their internal name, StringNums use their string value, -// and all other types fall back to String(). -func extractVarName(val StackValue) string { - switch v := val.(type) { - case *Symbol: - return v.Name() - case *StringNum: - return v.String() - default: - return val.String() - } -} - // AssignLeft assigns a value to a variable (for =: operator). // Stack order: value name =: (value on bottom, name on top). // This function pops name first (top of stack), then value. diff --git a/internal/rpn/rpn_parse.go b/internal/rpn/rpn_parse.go index 92292ae..51c64c7 100644 --- a/internal/rpn/rpn_parse.go +++ b/internal/rpn/rpn_parse.go @@ -405,6 +405,19 @@ func extractVariableName(token string) string { return token } +// extractVarName extracts a variable name from a StackValue. +// Handles Symbol and StringNum types, falls back to String(). +func extractVarName(val StackValue) string { + switch v := val.(type) { + case *Symbol: + return v.Name() + case *StringNum: + return v.String() + default: + return val.String() + } +} + // checkStackOverflow returns an error if the stack has reached the maximum size. func (r *RPN) checkStackOverflow(stack *Stack) error { if stack.Len() >= r.maxStack { -- cgit v1.2.3