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

Closured constants as default argument values don't work on functions with modifiers in the VM #27719

Closed
greglittlefield-wf opened this issue Nov 1, 2016 · 4 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@greglittlefield-wf
Copy link
Contributor

Default values for optional arguments that come from closured const variables don't work on functions with modifiers (async, async*, sync*).

This bug seems to be new in Dart 1.20, as it was working in 1.19.1.

This is not an issue for normal functions without modifiers, and not an issue for const variables that are top-level or within a class.

It also only occurs on the VM, and not dart2js.

This issue applies for both named and positional optional arguments.

Reduced test case
const topLevelConst = 'topLevelConst';

main() {
  const closureConst = 'closureConst';

  test({
    defaultFromTopLevelConst: topLevelConst,
    defaultFromClosureConst: closureConst
  }) async {
    print('Success!');
  }

  test();
}
error: line 8 pos 30: expression is not a valid compile-time constant
    defaultFromClosureConst: closureConst
                             ^

#0      Future.Future.microtask.<anonymous closure> (dart:async/future.dart:144)
#1      _microtaskLoop (dart:async/schedule_microtask.dart:41)
#2      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#3      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:149)
@greglittlefield-wf greglittlefield-wf changed the title Closured constants as default argument values don't work on functions with modifiers Closured constants as default argument values don't work on functions with modifiers in the VM Nov 1, 2016
@anders-sandholm anders-sandholm added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Nov 3, 2016
@crelier
Copy link
Contributor

crelier commented Nov 9, 2016

This issue is a duplicate of #27659, which was fixed on Oct 25.

@crelier crelier closed this as completed Nov 9, 2016
@greglittlefield-wf
Copy link
Contributor Author

@crelier Is this a duplicate? The names don't have to be the same for this issue to occur.

@crelier
Copy link
Contributor

crelier commented Nov 9, 2016

@greglittlefield-wf If I run your test case, I get "Success!". The error was due to a side effect of parsing the signature twice.

@greglittlefield-wf
Copy link
Contributor Author

Awesome, just wanted to make sure. Thanks for double-checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

3 participants