From 065dd252af1d2f1c70f8929058ea364481ab0658 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 24 May 2026 10:57:40 +0300 Subject: fix: replace fragile string matching in ResultStack with registry check ResultStack used strings.Contains(err.Error(), "unknown token") to decide whether to fall through to variable lookup. This is fragile and breaks if error messages change. Use the same pattern as handleOperator: check IsStandardOperator/IsHyperOperator directly. --- internal/rpn/rpn_ops.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/rpn/rpn_ops.go b/internal/rpn/rpn_ops.go index 9104eea..9208195 100644 --- a/internal/rpn/rpn_ops.go +++ b/internal/rpn/rpn_ops.go @@ -34,9 +34,8 @@ func (r *RPN) ResultStack(tokens []string) (string, error) { // Handle operator (common logic from executeOperator) if result, handled, err := r.executeOperator(stack, token); err != nil { - // If the error is not "unknown token", return it - // Otherwise, fall through to check for variable - if !strings.Contains(err.Error(), "unknown token") { + // If not a recognized operator, fall through to check for variable + if r.opRegistry.IsStandardOperator(token) || r.opRegistry.IsHyperOperator(token) { return "", err } } else if handled { -- cgit v1.2.3