Skip to content

[VM] Parameterized map literal used as a statement doesn't cause an error #3777

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 Jun 20, 2012 · 6 comments
Closed
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).

Comments

@DartBot
Copy link

DartBot commented Jun 20, 2012

This issue was originally filed by [email protected]


What steps will reproduce the problem?
Simplest example:
main() {
  <Map>{};
}

What is the expected output? What do you see instead?
Expecting a compile-time error per spec, not seeing one.

What version of the product are you using? On what operating system?
VM build r8882

@DartBot
Copy link
Author

DartBot commented Jun 20, 2012

This comment was originally written by @mhausner


Can you please reference the relevant spec portion? From what I remember, the intent was to break the ambiguity of a { at the beginning of a statement by specifying it to be a block, never a map literal. But a map literal with type arguments should be fine at the beginning of a statement.

@DartBot
Copy link
Author

DartBot commented Jun 21, 2012

This comment was originally written by [email protected]


11.2 Expression Statements
An expression statement consists of an expression other than a map literal (10.7).
expressionStatement:
expression? `;'
;
Execution of an expression statement e; proceeds by evaluating e.
It is a compile-time error if a map literal appears in a place where a statement
is expected.

@DartBot
Copy link
Author

DartBot commented Jun 21, 2012

This comment was originally written by @mhausner


Thank you. I just spoke to Gilad. He agrees that this should only apply to map literals that start with a curly brace. That is, a map literal with type arguments is ok. He will update the spec accordingly.

(The main issue this restriction solves is to disambiguate between map literal and beginning of a block, both of which start with a { token. )


cc @gbracha.

@gbracha
Copy link
Contributor

gbracha commented Jun 21, 2012

Relevant spec snippet in 0.11

An expression statement consists of an expression other than a non-constant map literal that has no explicit type arguments.

@DartBot
Copy link
Author

DartBot commented Jun 21, 2012

This comment was originally written by @mhausner


Thanks Gilad. This makes the bug "invalid". I'll mark it as "fixed" since we fixed the spec instead of the compiler :)


Added Area-Language, Fixed labels.

@DartBot
Copy link
Author

DartBot commented Oct 12, 2012

This comment was originally written by [email protected]


fix the last sentence of that chapter too, please

@DartBot DartBot added Type-Defect area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Oct 12, 2012
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).
Projects
None yet
Development

No branches or pull requests

2 participants