Files
carbon-lang/toolchain/check/testdata/if/fail_scope.carbon
T
Geoff Romer 7899154a21 Add "ERROR" to all error diagnostics (#3251)
This makes the difference between errors and lower-level diagnostics
visible to users, and aligns the toolchain's behavior with the
expectations in `driver_fuzzer.cpp`.
2023-09-26 16:52:49 +00:00

36 lines
1.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
//
// AUTOUPDATE
fn VarScope(b: bool) -> i32 {
if (b) {
var n: i32 = 2;
return n;
}
// CHECK:STDERR: fail_scope.carbon:[[@LINE+3]]:10: ERROR: Name `n` not found.
// CHECK:STDERR: return n;
// CHECK:STDERR: ^
return n;
}
// CHECK:STDOUT: file "fail_scope.carbon" {
// CHECK:STDOUT: %.loc7 = fn_decl @VarScope
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @VarScope(%b: bool) -> i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: if %b br !if.then else br !if.else
// CHECK:STDOUT:
// CHECK:STDOUT: !if.then:
// CHECK:STDOUT: %n: ref i32 = var "n"
// CHECK:STDOUT: %.loc9_18: i32 = int_literal 2
// CHECK:STDOUT: assign %n, %.loc9_18
// CHECK:STDOUT: %.loc9_9: i32 = bind_value %n
// CHECK:STDOUT: return %.loc9_9
// CHECK:STDOUT:
// CHECK:STDOUT: !if.else:
// CHECK:STDOUT: return <error>
// CHECK:STDOUT: }