antlr / antlr/antlr4

OrderedATNConfigSet has bad override of `configLookup` field

Open
#3,992 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
19k
Forks
3.5k
PR merge metrics
No merged PRs in 30d

Description

See https://github.com/antlr/antlr4/blob/47415e33c366cd9695d5c7e2586424692492deed/runtime/Dart/lib/src/atn/src/atn_config_set.dart#L290

In general, overriding fields is a bad idea in Dart. Both fields exist, but the one on the super class is only accessible through an explicit `super.` invocation.

In particular in this case, it is much worse since the subclass declares the field as final, it _only_ overrides the getter, and not the setter. So there is a setter still, which assigns to the _base class_ field, which can never be read (except through a `super.` invocation in the subclass).

In this case, the subclass does try to set the `configLookup` field, which has no effect, because that field is never read.

Contributor guide

Open the contributing guide

Research direction

Start at runtime/Dart/lib/src/atn/src/atn_config_set.dart around line 290 and compare the subclass and superclass declarations of configLookup. Trace where the field is assigned and read; done means the assignment affects the field used by OrderedATNConfigSet without leaving a shadowed field behind.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.