Skip to content

Injected binders should be resilient to GetBinder calls #75437

@jcouv

Description

@jcouv

Any time a binder is created/injected on-the-fly during binding, there is a risk that it could get dropped when it is used to bind an expression that involves getting more specific binders with GetBinder.

Using LocalInProgressBinder as an example (issue fixed in #75371):
This binder was injected when binding a local initializer to compute its constant value (new LocalInProgressBinder(...) in SourceLocalSymbol.MakeConstantTuple).
The binder keeps track of the const local being bound and helps avoid circularity issues.
But binding some expressions like checked(x) or x switch { ... } would involve a call to GetBinder and the LocalInProgressBinder would be lost, opening the compiler up to circularity issues.

Two possible solutions we discussed so far:

  1. avoid injecting the binder on-the-fly (use a binder factory instead)
  2. ensure that GetBinder maintains the injected binder

FYI @AlekseyTs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions