Skip to content

fix: string-left relational operator binding for custom types - #376

Merged
davideicardi merged 6 commits into
dynamicexpresso:masterfrom
israellot:fix-string-left-relational-operator-binding
Aug 20, 2026
Merged

fix: string-left relational operator binding for custom types#376
davideicardi merged 6 commits into
dynamicexpresso:masterfrom
israellot:fix-string-left-relational-operator-binding

Conversation

@israellot

Copy link
Copy Markdown
Contributor

Summary

Fixes string-left relational operator binding for custom types, e.g. "10" < m, "10" <= m, "10" > m, and "10" >= m.

Root cause

Relational operators special-cased any comparison with a string left operand and routed it through string.Compare. For string vs custom type, no matching string.Compare(string, T) exists, so a null MethodInfo was passed to Expression.Call, causing ArgumentNullException.

Fix
• Use the string.Compare shortcut only for string/string comparisons.
• Let string/custom relationals use normal binary operator resolution.
• Add fallback binding through a single implicit conversion when no direct user-defined operator matches.

Tests

Added NUnit coverage for all four relational operators in both operand orders, including direct string/custom operators, implicit-conversion fallback, and equality regressions.

@davideicardi davideicardi changed the title Fix string-left relational operator binding for custom types fix: string-left relational operator binding for custom types Aug 20, 2026
@davideicardi
davideicardi merged commit fac0ac8 into dynamicexpresso:master Aug 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants