Skip to content

Static variable declaration of the form "static var v = X" prevents further assigments to v if the value's type is not assignable to X's type #627

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

Closed
DartBot opened this issue Nov 29, 2011 · 6 comments
Labels
closed-cannot-reproduce Closed as we were unable to reproduce the reported issue legacy-area-analyzer Use area-devexp instead.
Milestone

Comments

@DartBot
Copy link

DartBot commented Nov 29, 2011

This issue was originally filed by [email protected]


What steps will reproduce the problem?

  1. Run this test with --component=dartc:
    class A {
      static var b = 1;
    }

main() {
  A.b = -1;
  Expect.equals(-1, A.b);
  A.b = "bar";
  Expect.equals("bar", A.b);
  Map bar = new Map<String, int>();
  A.b = bar;
  Expect.equals(bar, A.b);
}

  1. Observe the errors

What is the expected output? What do you see instead?
Spec says (Ch. 7.7):
A non-fi nal static variable declaration of the form static T v; or the form static T v = e; always induces an implicit static setter function (7.3) with signature
static void set v(T x)
whose execution sets the value of v to the incoming argument x.

Doesn't say the setter's argument type is fixed to the runtime type of e, Dynamic is implied and a value of any type should be possible to use.

What version of the product are you using? On what operating system?
latest Dart version, ubuntu 2.6.32-35-generic

@floitschG
Copy link
Contributor

Added Area-Compiler, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Mar 28, 2012

This comment was originally written by [email protected]


Just ran this test again, this is a problem with static analysis, not code generation.

@kasperl
Copy link

kasperl commented Apr 17, 2012

Removed Area-Compiler label.
Added Area-Analyzer label.

@danrubel
Copy link

danrubel commented Jun 4, 2012

Added this to the M1 milestone.

@DartBot
Copy link
Author

DartBot commented Jun 6, 2012

This comment was originally written by [email protected]


Just ran the above test again and there are no errors output.


Added CannotReproduce label.

@DartBot
Copy link
Author

DartBot commented Jun 7, 2012

This comment was originally written by [email protected]


Just checked with a recent build of dartc and there was no error as well.
Looks like it's been fixed at some point

@DartBot DartBot added Type-Defect legacy-area-analyzer Use area-devexp instead. closed-cannot-reproduce Closed as we were unable to reproduce the reported issue labels Jun 7, 2012
@DartBot DartBot added this to the M1 milestone Jun 7, 2012
dart-bot pushed a commit that referenced this issue Oct 25, 2019
Update spec_parser to enable configurableUri in deferred imports,
make cascade syntax compositional, include `extension` declarations,
add `late` as a built-in identifier, and reorder the lexical rules for
single words such that they are grouped into reserved words, built-in
identifiers, and "other words known by the grammar".

Cf. language issue #615, #627, #628, #638.

Change-Id: If60b2ba2ca0e7d4bbc9b4e886857f657fb14c809
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121991
Reviewed-by: Lasse R.H. Nielsen <[email protected]>
Commit-Queue: Erik Ernst <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-cannot-reproduce Closed as we were unable to reproduce the reported issue legacy-area-analyzer Use area-devexp instead.
Projects
None yet
Development

No branches or pull requests

4 participants