Skip to content

Unable to create a static map of functions #2402

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 Apr 3, 2012 · 3 comments
Closed

Unable to create a static map of functions #2402

DartBot opened this issue Apr 3, 2012 · 3 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Apr 3, 2012

This issue was originally filed by @tomyeh


What steps will reproduce the problem?

  1. DartVM doesn't access the following code.

typedef void Func();
Map<String, Func> funcs = const {
  "foo", () {}
};

What is the expected output? What do you see instead?
A constant map shall be created. But, DartVM throws an exception saying "expression mst be a compile time constatn".

What version of the product are you using? On what operating system?
Dartium 129764 on Linux

@DartBot
Copy link
Author

DartBot commented Apr 3, 2012

This comment was originally written by [email protected]


I suppose you wanted to write

"foo": () {}

But other than that -- yes, closures aren't compile time constants, so this is the correct behavior (currently).

Compile-time-constant closures is already mentioned in http://dartbug.com/1652 -- if that is supported, then your example would work.

Also, there is http://dartbug.com/144 which says that static functions might be considered compile-time constants in the future, which might be good enough for a lot of cases (but it is only a subset of http://dartbug.com/1652).

@kasperl
Copy link

kasperl commented Apr 11, 2012

Added Area-Language, Triaged labels.

@gbracha
Copy link
Contributor

gbracha commented Apr 12, 2012

As comment 1 says: the behavior is as intended. In some cases, we may be able to make functions be constant - but not in all. I'm merging this into 1652.


Set owner to @gbracha.
Removed Type-Defect label.
Added Type-Enhancement, Duplicate labels.
Marked as being merged into #1652.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report labels Apr 12, 2012
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
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). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants