Files
carbon-lang/toolchain/driver/testdata/fail_flush_errors.carbon
T
Jon Ross-Perkins 77918d023b Make symbolic local bindings a TODO (#6449)
Per discussion, makes all symbolic local bindings a TODO. We should
implement them more correctly before making them operable. Right now
things partially work, but because constants behave mostly right in the
symbolic situations under tests. More broadly, it has incorrect behavior
and crashes, thus the TODO.

This converts most tests using `let` to instead using parameters, but
leaves some behind where a conversion either didn't make sense (e.g. in
`let` tests) or a conversion was unclear to me (multi-layer `let`, which
relies more on planned behavior that seems more bespoke to a local
`let`).

In let's `fail_generic.carbon`, there's a "// TODO: Should this be
valid?" that I'm removing because my understanding is the code in
question should be valid (the file is merged into let's
`generic.carbon`).

Refactoring `HandleAnyBindingPattern` a little because there's a TODO to
make it shorter, and it seemed like a reasonable drive-by change (let me
know if you think there's more I should do, or if I should remove said
TODO even though it's still a bit long).

Fixes #5982
2025-12-10 18:11:58 +00:00

47 lines
2.0 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
//
// This test is validating that the delayed error flush doesn't break on string
// lifetimes.
//
// ARGS: --include-diagnostic-kind compile --no-prelude-import %s
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/fail_flush_errors.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/fail_flush_errors.carbon
fn F() {
// Create diagnostics containing string references, and trigger reallocation
// of the string table.
// CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared1` not found [NameNotFound]
// CHECK:STDERR: undeclared1;
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR:
undeclared1;
// Add the name into the string table from the tokenized buffer's string
// literal storage. Use a hex escape to ensure that the tokenized buffer
// allocates separate storage for the result.
// CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: `Core.String` implicitly referenced here, but package `Core` not found [CoreNotFound]
// CHECK:STDERR: "undec\x6Cared2";
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
// CHECK:STDERR:
"undec\x6Cared2";
// CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared2` not found [NameNotFound]
// CHECK:STDERR: undeclared2;
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR:
undeclared2;
// Add the name into the string table via a declaration rather than an expression.
if (true) { let undeclared3: () = (); }
// CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared3` not found [NameNotFound]
// CHECK:STDERR: undeclared3;
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR:
undeclared3;
}