Skip to content

No syntax error when VB compiler generates skipped tokens for nullable ? syntax inside cref #2196

@shyamnamboodiripad

Description

@shyamnamboodiripad

When I type the below code and turn on xml doc comment generation in the project settings, I noticed that ? is actually parsed as a skipped token - which indicates that the syntax was erroneous. Yet the compiler gives me no warning (which means that the cref will not be emitted correctly).

capture3

capture

  • If I replace Integer? with Nullable(Of Integer), there is no longer any skipped tokens and no errors either. However, I am not sure whether this is legal - in C# we only allow unconstructed generic types in crefs (except when specifying parameter types) - so it is legal to say <see cref="Nullable{T}"/> but it is not legal to say <see cref="Nullable{Integer}"/>. In any case, if I inspect symbols for Nullable(Of Integer) and Integer using the syntax visualizer, I can see that both identifiers bind correctly (see screenshot below). So I guess this must be legal in VB.
  • But if this is legal in VB, then shouldn't using the short form syntax Integer? be legal too? Why does the parser skip the ? token? And why doesn't it produce any errors if this is illegal.

capture2

  • The specific reason I am logging this issue is that this inconsistent behavior makes detection of when we should offer to simplify Nullable(Of Something) to Something? within crefs in VB quite difficult. (Looks like VB is inconsistent with C# here + the VB compiler is also inconsistent with itself w.r.t interchangeability of short and long form syntax for nullables.) But this also feels like it would impact any tools / extensions that want to do analysis within crefs.

Metadata

Metadata

Assignees

Labels

Area-CompilersBugConcept-APIThis issue involves adding, removing, clarification, or modification of an API.help wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions