Skip to content

docs: describe the binder contract and how errors are reported - #39

Merged
rameel merged 1 commit into
mainfrom
docs/describe-binder-contract
Nov 19, 2026
Merged

rameel merged 1 commit into
mainfrom
docs/describe-binder-contract

Conversation

@rameel

@rameel rameel commented Nov 19, 2026

Copy link
Copy Markdown
Owner

The XML comments left out how the expression builder uses a binder and how parsing and evaluation report errors. This PR describes them:

  • Binder did not explain Context, or that an unqualified name is bound with a null type and isStatic set to true, in which case the binder can return an instance member of the context.
  • ContextAwareBinder and DefaultBinder did not say what they resolve: the members of the context, a predefined set of types, and the registered types, matched without regard to case. RegisterType did not say that a type is registered under its simple name, and the description of importAsStatic read as if instance members became static.
  • Parse did not say that its result describes the error, Evaluate did not mention the ArgumentException it throws for an invalid expression, and ExpressionBuilder.Visit mentioned ParseErrorException only for a stack that is too small.
  • ParseErrorException was described as a parsing error only, although it also reports errors found while building the expression tree.

It also explains that Evaluate with an object context uses its runtime type, how Subparser differs from Parser, that Identifier holds operators as well as names, that MemberAccess covers members of types and methods in calls, that Unary covers conversions, and that a literal can be a character or null.

Two behaviors are left undocumented because they need separate decisions: RegisterType silently ignores a type whose simple name matches a predefined type, so the static members of a DateTime or Guid context are not available without the type name, and Evaluate<TResult> converts the result with an unchecked explicit conversion, so Evaluate<byte>("300") returns 44.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

The XML comments left out how the expression builder uses a binder
and how parsing and evaluation report errors:

- Binder did not explain Context, or that an unqualified name is
  bound with a null type and isStatic set to true, in which case the
  binder can return an instance member of the context.
- ContextAwareBinder and DefaultBinder did not say what they resolve:
  the members of the context, a predefined set of types, and the
  registered types, matched without regard to case. RegisterType did
  not say that a type is registered under its simple name, and the
  description of importAsStatic read as if instance members became
  static.
- Parse did not say that its result describes the error, Evaluate
  did not mention the ArgumentException it throws for an invalid
  expression, and ExpressionBuilder.Visit mentioned ParseErrorException
  only for a stack that is too small.
- ParseErrorException was described as a parsing error only, although
  it also reports errors found while building the expression tree.

It also explains that Evaluate with an object context uses its
runtime type, how Subparser differs from Parser, that Identifier
holds operators as well as names, that MemberAccess covers members
of types and methods in calls, that Unary covers conversions, and
that a literal can be a character or null.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rameel
rameel merged commit b96c12d into main Nov 19, 2026
1 check passed
@rameel
rameel deleted the docs/describe-binder-contract branch November 19, 2026 10:43
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.

1 participant