Files
carbon-lang/toolchain/check/testdata/eval/unexpected_runtime.carbon
T
Dana Jansens e7ed217d4e Require all constraints in where to have a designator (#7282)
Instead of requiring just one to have a designator, require each one.
You can't write `(type where A == B) & (type where C == .Self)` because
`A == B` has no designator. If the two facet types are combined into a
single `where` syntactically, their meaning does not change, and what we
allow should not change either. That is, `type where A == B and C ==
.Self` should be rejected since `A == B` does not contain a designator.

The design is also updated to make this clear.
2026-06-02 17:11:59 +00:00

97 lines
3.1 KiB
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/eval/unexpected_runtime.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/eval/unexpected_runtime.carbon
// --- fail_unexpected_runtime_base.carbon
library "[[@TEST_NAME]]";
var x: type;
interface Z {
let T:! type;
}
class D {
// CHECK:STDERR: fail_unexpected_runtime_base.carbon:[[@LINE+4]]:18: error: cannot evaluate type expression [TypeExprEvaluationFailure]
// CHECK:STDERR: extend impl as x where .T = () {}
// CHECK:STDERR: ^
// CHECK:STDERR:
extend impl as x where .T = () {}
}
// --- fail_unexpected_runtime_rewrite_lhs.carbon
library "[[@TEST_NAME]]";
var x: type;
interface Z {
let T:! type;
}
class D {
// CHECK:STDERR: fail_unexpected_runtime_rewrite_lhs.carbon:[[@LINE+8]]:18: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
// CHECK:STDERR: extend impl as Z where x = () {}
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_unexpected_runtime_rewrite_lhs.carbon:[[@LINE+4]]:28: error: requirement can only use `=` after `.member` designator [RequirementEqualAfterNonDesignator]
// CHECK:STDERR: extend impl as Z where x = () {}
// CHECK:STDERR: ^
// CHECK:STDERR:
extend impl as Z where x = () {}
}
// --- fail_unexpected_runtime_rewrite_rhs.carbon
library "[[@TEST_NAME]]";
var x: type;
interface Z {
let T:! type;
}
class D {
// CHECK:STDERR: fail_unexpected_runtime_rewrite_rhs.carbon:[[@LINE+4]]:31: error: expression is runtime; expected constant [EvalRequiresConstantValue]
// CHECK:STDERR: extend impl as Z where .T = x {}
// CHECK:STDERR: ^
// CHECK:STDERR:
extend impl as Z where .T = x {}
}
// --- fail_unexpected_runtime_impls_lhs.carbon
library "[[@TEST_NAME]]";
var x: type;
interface Z(T:! type) {}
class D {
// CHECK:STDERR: fail_unexpected_runtime_impls_lhs.carbon:[[@LINE+4]]:29: error: cannot evaluate type expression [TypeExprEvaluationFailure]
// CHECK:STDERR: extend impl as type where x impls Z(.Self) {}
// CHECK:STDERR: ^
// CHECK:STDERR:
extend impl as type where x impls Z(.Self) {}
}
// --- fail_unexpected_runtime_impls_rhs.carbon
library "[[@TEST_NAME]]";
var x: type;
interface Z {}
class D {
// CHECK:STDERR: fail_unexpected_runtime_impls_rhs.carbon:[[@LINE+4]]:41: error: cannot evaluate type expression [TypeExprEvaluationFailure]
// CHECK:STDERR: extend impl as type where .Self impls x {}
// CHECK:STDERR: ^
// CHECK:STDERR:
extend impl as type where .Self impls x {}
}