mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 06:51:03 +01:00
* Add assertion to detect UB in interpreter.cpp This change, applied to6e5070d("Adapting jsiek's executable semantics tooling for commit. (#237)"), causes the if2.6c test to segfault. Becase the assertion fires only when `stmt == nullptr` and no code has permission to change `stmt` (it is `const`) before it is dereferenced in the `switch`, and nothiing in `PrintStatement` is supposed to exit the program, the assertion is a valid change that detects a bug. The crash was originally manifest in29a5994("Executable Semantics: 1st-class stacks (#296)"). * Temporarily disable the if2 test pending #311 See https://github.com/carbon-language/carbon-lang/issues/311 * [executable semantics] Record exit code on expected error. This will prevent a final segfault from sneaking by, detected as a passing test. A more principled follow-up commit would bottleneck detected error exit reporting and have it write something to std::cerr that can be recognized.
45 lines
925 B
Plaintext
45 lines
925 B
Plaintext
********** source program **********
|
|
choice Ints {
|
|
alt None ();
|
|
alt One Int;
|
|
alt Two (0 = Int, 1 = Int);
|
|
}
|
|
fn main () -> Int {
|
|
var auto: x = Ints.None();
|
|
var auto: y = Ints.One(0 = 42);
|
|
var auto: n = 0;
|
|
match (y) {
|
|
case Ints.None =>
|
|
n = (n + 2);
|
|
case Ints.One(0 = auto: x) =>
|
|
n = ((x + 1) - 42);
|
|
case Ints.Two(0 = auto: a, 1 = auto: b) =>
|
|
n = 2;
|
|
}
|
|
match (x) {
|
|
case Ints.One(0 = auto: x) =>
|
|
n = (x + 2);
|
|
case Ints.None() =>
|
|
n = (n - 1);
|
|
case Ints.Two(0 = auto: x, 1 = auto: y) =>
|
|
n = 5;
|
|
}
|
|
return n;
|
|
|
|
}
|
|
********** type checking **********
|
|
--- step exp () --->
|
|
--- step exp Int --->
|
|
--- step exp (0 = Int, 1 = Int) --->
|
|
--- step exp Int --->
|
|
--- handle value Int with (0 = Int, 1 = Int)<1>(Int,) --->
|
|
--- step exp Int --->
|
|
--- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) --->
|
|
--- step exp Int --->
|
|
--- step exp Int --->
|
|
--- step exp auto --->
|
|
13: type error in call
|
|
expected: Int
|
|
actual: Tuple(0 = Int)
|
|
EXIT CODE: 255
|