mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 16:20:09 +01:00
This also clusters the various `var` tests. This tests similar patterns for a few syntaxes, but `fn f(x: i32, i32) {}` and local variables `var (x: i32, i32);` and `var i32;` were the crashers I found.
In `fn`, the `x: i32,` is helpful to convince the parser that this is valid syntax.
Fixes #2778
25 lines
515 B
Plaintext
25 lines
515 B
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
|
|
// RUN: %{explorer-run}
|
|
// RUN: %{explorer-run-trace}
|
|
// CHECK:STDOUT: result: 0
|
|
|
|
package ExplorerTest api;
|
|
|
|
// Test that mutations to a global variable in one function is visible
|
|
// in another function.
|
|
|
|
var flag: i32 = 1;
|
|
|
|
fn flipFlag() {
|
|
flag = 0;
|
|
}
|
|
|
|
fn Main() -> i32 {
|
|
flipFlag();
|
|
return flag;
|
|
}
|