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

Uri.queryParametersAll: JSArray is not a subtype of type 'List<String>' #33371

Closed
chalin opened this issue Jun 6, 2018 · 6 comments
Closed
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core
Milestone

Comments

@chalin
Copy link
Contributor

chalin commented Jun 6, 2018

From @jtmcdole on June 6, 2018 19:25

I expect this to run:

main() {
  var uri = Uri.parse('https://foo.bar.com/this/is/a/path?foo=foo1&foo=foo2&bar=baz');
  print(uri.queryParametersAll);
  print(uri.queryParameters);
}

Instead I get:

Uncaught exception:
TypeError: Instance of 'JSArray': type 'JSArray' is not a subtype of type 'List<String>'

Copied from original issue: dart-lang/site-www#909


You can try it here: https://dartpad.dartlang.org/e0fe1365f6094701c7632562a17e13b7

@chalin
Copy link
Contributor Author

chalin commented Jun 6, 2018

Thanks for reporting this issue @jtmcdole.

The error is only reported when uri.queryParametersAll is printed. It seems that there might be a Dart 2 type error in this code:

sdk/sdk/lib/core/uri.dart

Lines 1918 to 1929 in 8c20f26

Map<String, List<String>> get queryParametersAll {
if (_queryParameterLists == null) {
Map queryParameterLists = _splitQueryStringAll(query);
for (var key in queryParameterLists.keys) {
queryParameterLists[key] =
new List<String>.unmodifiable(queryParameterLists[key]);
}
_queryParameterLists =
new Map<String, List<String>>.unmodifiable(queryParameterLists);
}
return _queryParameterLists;
}

The call to _splitQueryStringAll(query) returns a Map<dynamic, dynamic> rather than the expected Map<String, List<String>>. That might causing the problem.

cc @kevmoo @kwalrath

@kevmoo kevmoo added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core preview-dart-2 labels Jun 6, 2018
@kevmoo kevmoo added this to the Dart2Stable milestone Jun 6, 2018
@kevmoo
Copy link
Member

kevmoo commented Jun 6, 2018

@lrhn ?

@chalin
Copy link
Contributor Author

chalin commented Jun 6, 2018

Btw, DartPad is currently using Dart SDK 2.0.0-dev.59.0.

@chalin
Copy link
Contributor Author

chalin commented Jun 6, 2018

@lrhn
Copy link
Member

lrhn commented Jun 7, 2018

The bug is in ConstantMap.from in the dart2js runtime system. It assumes that the input map has the correct key type, which isn't guaranteed by the uses.
We already have (untriaged) status-file entries marking dart2js as crashing on uri_test and uri_parameters_all_test.

@rakudrama
Copy link
Member

Fixed by b9381d3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core
Projects
None yet
Development

No branches or pull requests

5 participants