mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:27:17 +00:00
45c9d8a25e
Change-Id: Ia164adaf5da313cae4db2b3b326a909e57d8c07c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192200 Reviewed-by: Jake Macdonald <jakemac@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Kallen Tu <kallentu@google.com>
22 lines
678 B
Dart
22 lines
678 B
Dart
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Tests recursive function calls for const functions which have a cycle in the
|
|
// dependencies.
|
|
|
|
// SharedOptions=--enable-experiment=const-functions
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
const dependsOnB = b;
|
|
// ^
|
|
// [cfe] Constant evaluation error:
|
|
const b = fn(4);
|
|
// ^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
|
int fn(int a) {
|
|
if (a == 1) return dependsOnB;
|
|
return dependsOnB * fn(a - 1);
|
|
}
|