dotnet / dotnet/csharpstandard

dynamic – missing contextual resolution rules

Open
#1,714 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

The contextual keyword `dynamic` lacks contextual resolution rules, these need to be defined and added to the Standard.

---

### Explanation

A token being a contextual keyword, means either:

1. There is a particular context in the grammar where the token is always recognised as a keyword and other places where it is an identifier. An example is the `get` contextual keyword for property accessors which may otherwise be freely used as an identifier. There are no resolution rules required for `get`, the meaning comes from its context.
2. In some contexts a token ***may*** have a special meaning dependant upon the environment. An example is the `var` contextual keyword which *may* be used in declaration statements, in patterns, etc. In such contexts if there is an accessible type named “var” in the environment the contextual meaning does not apply. The Standard contains resolution rules to determined whether the contextual meaning applies.

`dynamic` is an example of (2), e.g. it may be used as the name of a type (class, struct, enum, record) as well as a contextual keyword. The Standard is lacking resolution rules.

Contributor guide

Open the contributing guide

Research direction

Start by locating the Standard's existing contextual-keyword resolution rules, especially the rules discussed for `var`, and compare them with the `dynamic` cases described in this issue. Done means the Standard defines resolution rules for when `dynamic` retains its contextual meaning versus when an accessible type named `dynamic` takes precedence.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.