diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-24 13:58:54 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-24 13:58:54 +0300 |
| commit | 4c64d3869230b2aa22f7f2635e0851e355b24ca4 (patch) | |
| tree | ae77fefee64d158e38b7245b8073bf33adae8586 | |
| parent | 52e8a67dbd1077b852a815befbe0d246a938cf92 (diff) | |
fix: remove dead "=" entry from operator registry (fj)
The dispatchToken guard for standalone "=" always fires before the
registry lookup, making the "=" registration in operator_registry.go
dead code. Assignment with "=" is handled at the expression level by
handleStandardAssign, not via the stack-level operator registry.
Also update related tests:
- TestAssignmentOperatorRegistry: remove "=" from registered operators
- TestResultStackErrors: "=" is no longer an operator, expects
"unknown token" instead of "insufficient operands"
| -rw-r--r-- | internal/rpn/assignment_test.go | 2 | ||||
| -rw-r--r-- | internal/rpn/operator_registry.go | 1 | ||||
| -rw-r--r-- | internal/rpn/rpn_test.go | 4 |
3 files changed, 3 insertions, 4 deletions
diff --git a/internal/rpn/assignment_test.go b/internal/rpn/assignment_test.go index 8c6a4b2..82d4a12 100644 --- a/internal/rpn/assignment_test.go +++ b/internal/rpn/assignment_test.go @@ -264,7 +264,7 @@ func TestAssignmentOperatorRegistry(t *testing.T) { reg := NewOperatorRegistry(ops) // Verify assignment operators are registered as standard operators - for _, op := range []string{"=", ":=", "=: "} { + for _, op := range []string{":=", "=: "} { trimmed := op if op == "=: " { trimmed = "=:" diff --git a/internal/rpn/operator_registry.go b/internal/rpn/operator_registry.go index b459f04..67898e5 100644 --- a/internal/rpn/operator_registry.go +++ b/internal/rpn/operator_registry.go @@ -88,7 +88,6 @@ func (r *OperatorRegistry) registerStackOperators(op *Operations) { // registerVariableOperators registers assignment and conversion operators. func (r *OperatorRegistry) registerVariableOperators(op *Operations) { - r.registerStandardOperator("=", func(stack *Stack) error { return op.AssignRight(stack) }) r.registerStandardOperator(":=", func(stack *Stack) error { return op.AssignRight(stack) }) r.registerStandardOperator("=:", func(stack *Stack) error { return op.AssignLeft(stack) }) r.registerStandardOperator("convert", func(stack *Stack) error { return op.Convert(stack) }) diff --git a/internal/rpn/rpn_test.go b/internal/rpn/rpn_test.go index 133ca85..bd8e0fa 100644 --- a/internal/rpn/rpn_test.go +++ b/internal/rpn/rpn_test.go @@ -590,9 +590,9 @@ func TestResultStackErrors(t *testing.T) { expectedError: "insufficient operands", }, { - name: "insufficient operands for =", + name: "unknown token (= is not an operator)", input: []string{"="}, - expectedError: "insufficient operands", + expectedError: "unknown token", }, } |
