Skip to content

const maps with type entries doesn't work properly #17123

Closed
@sigmundch

Description

@sigmundch

It took me a while to figure out a bug related to this. Dart2js currently allows const maps with types as keys, but lookup functions fail.

Here is a simple example that reproduces the problem:

    class A {}
    var m1 = { A: 1};
    const m2 = const {A: 2};
    
    main() {
      var t = new A().runtimeType;
      print('${m1[A]} ${m2[A]} ${m1[t]} ${m2[t]}');
      print(m2.keys.first == t)
    }
    

This program works in the vm, there it prints:
   1 2 1 2
   true

in dart2js it prints:
   1 2 1 null
   true

Metadata

Metadata

Assignees

Labels

closed-invalidClosed as we don't believe the reported issue is generally actionableweb-dart2js

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions