mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
Issue 47422. Fix crash in constant evaluation when the number of positional arguments is less the the number of required positional parameters.
Bug: https://github.com/dart-lang/sdk/issues/47422 Change-Id: I3d45b12a131c3cb4d7f08680fc906d6f33d056c2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216140 Reviewed-by: Samuel Rawlins <srawlins@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
12f7507af2
commit
9c10d2b7ff
|
@ -2206,7 +2206,7 @@ class _InstanceCreationEvaluator {
|
|||
if (baseParameter.isNamed) {
|
||||
argumentValue = _namedValues[baseParameter.name];
|
||||
errorTarget = _namedNodes[baseParameter.name];
|
||||
} else if (i < arguments.length) {
|
||||
} else if (i < _argumentValues.length) {
|
||||
argumentValue = _argumentValues[i];
|
||||
errorTarget = arguments[i];
|
||||
}
|
||||
|
|
|
@ -29,6 +29,21 @@ main() {
|
|||
]);
|
||||
}
|
||||
|
||||
test_const_namedArgument_insteadOfRequiredPositional() async {
|
||||
await assertErrorsInCode(r'''
|
||||
class A {
|
||||
const A(int p);
|
||||
}
|
||||
main() {
|
||||
const A(p: 0);
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 41, 13),
|
||||
error(CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS, 48, 6),
|
||||
error(CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER, 49, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_const_super() async {
|
||||
await assertErrorsInCode(r'''
|
||||
class A {
|
||||
|
|
Loading…
Reference in a new issue