Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing warning for duplicate parameters #27174

Closed
DanTup opened this issue Aug 27, 2016 · 2 comments
Closed

Missing warning for duplicate parameters #27174

DanTup opened this issue Aug 27, 2016 · 2 comments
Labels
closed-duplicate Closed in favor of an existing report

Comments

@DanTup
Copy link
Collaborator

DanTup commented Aug 27, 2016

The following code doesn't generate any warnings:

class MyClass {
  String name;
  String doc;

  MyClass(String name, String doc, this.doc);
}

main() {
  var a = new MyClass("test", "test", "test");
  print(a.name);
}

However it gives this error when run:

c:\Users\danny\Desktop\DartSample>dart test.dart
'file:///c:/Users/danny/Desktop/DartSample/test.dart': error: line 5 pos 41: duplicate formal parameter 'doc'
  MyClass(String name, String doc, this.doc);

Presumably there should be a warning about the duplicate parameters.

@eernstg
Copy link
Member

eernstg commented Aug 27, 2016

Thanks for the report! However, this issue is currently being resolved:

As per #26655, we are introducing the ability to access initializing formal parameters (like the third parameter this.doc in your example) in the initializer list. This makes the behavior of dart correct (there will be a name clash), and the analyzer will be updated to diagnose this kind of name clash as a compile time error.

@eernstg eernstg closed this as completed Aug 27, 2016
@lrhn
Copy link
Member

lrhn commented Aug 27, 2016

So this issue is effectively a duplicate of #26658.

@lrhn lrhn added the closed-duplicate Closed in favor of an existing report label Aug 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

3 participants