dart-lang / dart-lang/language

prohibit or at least warn about type parameter names shadowing existing type names

Open
#849 2 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

Newcomers to Dart sometimes end up writing code like this:

```
void foo(int x) {
}
```

where `int` in `foo` becomes a reference to type parameter, rather than just a reference to `int`.

This later might lead to all kinds of confusing things and errors like `int` is not a subtype of `int`.

We should consider either completely forbidding this or at least mandate a warning to make this new user friendly.

/cc @leafpetersen @lrhn @eernstg @munificent

Contributor guide

Open the contributing guide

Research direction

Start by examining the Dart example `void foo(int x) {}` and the resulting type-resolution behavior. The issue is complete only after the language design chooses prohibition or warning behavior and specifies the corresponding user-facing result.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.