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

Constructor differences in dartc compared to dart_bin and frogsh #360

Closed
DartBot opened this issue Nov 7, 2011 · 4 comments
Closed

Constructor differences in dartc compared to dart_bin and frogsh #360

DartBot opened this issue Nov 7, 2011 · 4 comments
Labels
closed-invalid Closed as we don't believe the reported issue is generally actionable

Comments

@DartBot
Copy link

DartBot commented Nov 7, 2011

This issue was originally filed by financeC...@gmail.com


What steps will reproduce the problem?

  1. Build bleeding dart in debug.
    adam@ubuntu:~/dart_bleeding/dart$ ./tools/build.py -m debug --arch=ia32
  2. Create example.
    adam@ubuntu:/tmp$ cat > ConstructorExample.dart << EOF
    class A {
      int a;
    }

class B extends A {
  B(this.a);
  //B(a) {
  // this.a = a;
  //}
}

class ConstructorExample {

  ConstructorExample() {
  }
  void run() {
    print("run");
  }
}

void main() {
  new ConstructorExample().run();
}

EOF

  1. Run commands and note output:
    adam@ubuntu:/tmp$ ~/dart_bleeding/dart/out/Debug_ia32/dart_bin ./ConstructorExample.dart
    run
    adam@ubuntu:/tmp$ ~/dart_bleeding/dart/out/Debug_ia32/dartc ./ConstructorExample.dart
    ConstructorExample.dart/ConstructorExample.dart:6: Could not match parameter initializer 'this.a' with any field
         5: class B extends A {
         6: B(this.a);

Compilation failed with 1 problem.
adam@ubuntu:/tmp$ ~/dart_bleeding/dart/frog/frogsh ./ConstructorExample.dart
run

What is the expected output?
Expected all commands to exit successfully.
 
What do you see instead?
The dartc exits with error when it reaches the constructor of a class that tries to set a field in the parent class.

What version of the product are you using?
adam@ubuntu:~/dart_bleeding/dart$ svn info
Path: .
URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Repository Root: http://dart.googlecode.com/svn
Repository UUID: 260f80e4-7a28-3924-810f-c04153c831b5
Revision: 1235
Node Kind: directory
Schedule: normal
Last Changed Author: jimhug@google.com
Last Changed Rev: 1235
Last Changed Date: 2011-11-05 12:40:45 -0700 (Sat, 05 Nov 2011)

On what operating system?

adam@ubuntu:~/dart_bleeding/dart$ uname -a
Linux ubuntu 2.6.38-11-generic #­50-Ubuntu SMP Mon Sep 12 21:18:14 UTC 2011 i686 i686 i386 GNU/Linux

Adams-MacBook-Air:~ adam$ uname -a
Darwin Adams-MacBook-Air.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64

Please provide any additional information below.
Noticed this difference when using the dart editor. The dart editor seems to let auto complete resolve the field. When auto-compile triggers the error is reported in the dart editor.

@DartBot
Copy link
Author

DartBot commented Nov 8, 2011

This comment was originally written by drfibonacci@google.com


Added Area-Compiler, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Nov 22, 2011

This comment was originally written by zundel@google.com


Added Accepted label.

@DartBot
Copy link
Author

DartBot commented Nov 22, 2011

This comment was originally written by zundel@google.com


I created a separate bug for the VM

http://code.google.com/p/dart/issues/detail?id=556

patch up at:
http://codereview.chromium.org/8633015

@DartBot
Copy link
Author

DartBot commented Nov 30, 2011

This comment was originally written by zundel@google.com


Turns out this example is invalid dart. froghs and the VM acceept the example above only because B is never instantiated. See issue #556:

Comment 3 by project member gbracha@google.com, Today (5 hours ago)
The example is illegal. The spec says:

A final variable can only be assigned once, when it is initialized, or a compile-time error occurs.

I may add this as an example to the spec. If this is accepted by any of our implementations, it's wrong.


Set owner to zundel@google.com.
Added Invalid label.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-invalid Closed as we don't believe the reported issue is generally actionable
Projects
None yet
Development

No branches or pull requests

1 participant