diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-24 10:32:34 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-24 10:32:34 +0300 |
| commit | fc071785f821395cf213d760654abb4f115f119c (patch) | |
| tree | b659ff2b0fae17eefc2ffead861ebbca8b738d9c | |
| parent | 03136db76ee7b60a3570f6c20c416ae9f53ec3ae (diff) | |
rpn: replace fragile error message parsing with direct registry check
In handleOperator, replace strings.Contains(err.Error(), "unknown token")
with a direct check against opRegistry.IsStandardOperator and
opRegistry.IsHyperOperator. This is robust against future changes to
error message text.
| -rw-r--r-- | internal/rpn/rpn_parse.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/internal/rpn/rpn_parse.go b/internal/rpn/rpn_parse.go index 4035e3d..0d96d3f 100644 --- a/internal/rpn/rpn_parse.go +++ b/internal/rpn/rpn_parse.go @@ -407,7 +407,7 @@ func (r *RPN) handleOperator(stack *Stack, token string, tokenIndex int) (string // If it's an unknown token error and we're at the evaluate stage, // it might be a bare identifier that should be a symbol // Check if the caller is the main evaluate loop - if strings.Contains(err.Error(), "unknown token") { + if !r.opRegistry.IsStandardOperator(token) && !r.opRegistry.IsHyperOperator(token) { // For bare identifiers, push a Symbol instead of returning error // But only if it looks like a valid identifier (alphanumeric/underscore, starts with letter/_) // Don't push symbols for tokens with special characters like %, ., etc. |
