Add syntax for package and library (#792)

Doesn't add much logic, only takes advantage of parser structure for the ordering enforcement.

Note import_nonexistent tests should probably fail, but writing import tests needs a chain of functionality, and I figured I'd just start adding some to validate the syntax (not adding existent imports because that'd require multi-file structure).
This commit is contained in:
Jon Meow
2021-09-02 16:01:15 -07:00
committed by GitHub
parent 0980df65cd
commit a03536a196
152 changed files with 433 additions and 63 deletions
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test that assignment performs a copy and does not create an alias.
fn main() -> i32 {
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test that assignment performs a copy and does not create an alias.
fn main() -> i32 {
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var x: i32 = 0;
{
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var x: i32 = 0;
{
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var x: i32 = 2;
while (true) {
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
choice Ints {
None,
One(i32),
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
class Point {
var x: i32;
var y: i32;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
class Point {
var x: i32;
var y: i32;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
class Point {
var x: i32;
var y: i32;
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
class Point {
var x: i32;
var y: i32;
@@ -1,2 +1,2 @@
COMPILATION ERROR: executable_semantics/testdata/class_field_access_mismatch.carbon:11: class Point does not have a field named z
COMPILATION ERROR: executable_semantics/testdata/class_field_access_mismatch.carbon:13: class Point does not have a field named z
EXIT CODE: 255
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
class Point {
var x: i32;
var y: i32;
+1 -1
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: executable_semantics/testdata/class_field_mismatch.carbon:11: type error in call
COMPILATION ERROR: executable_semantics/testdata/class_field_mismatch.carbon:13: type error in call
expected: (x = i32, y = i32)
actual: (x = i32, z = i32)
EXIT CODE: 255
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
class Point {
var x: i32;
var y: i32;
+1 -1
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: executable_semantics/testdata/class_field_missing.carbon:11: type error in call
COMPILATION ERROR: executable_semantics/testdata/class_field_missing.carbon:13: type error in call
expected: (x = i32, y = i32)
actual: (x = i32)
EXIT CODE: 255
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var x: auto = 2;
while (not (x == 0)) {
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test that creating a continuation doesn't do anything.
fn main() -> i32 {
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test creating and running a continuation.
fn main() -> i32 {
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test pausing a continuation with `__await` and restarting it with
// `__run`.
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Assignment for continuations is shallow, so `k2` refers to the same
// continuation as `k1`.
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test access to block-scoped variables upon resuming a continuation.
fn main() -> i32 {
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test recursive functions inside continuations.
var current: i32 = 0;
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test the way in which copying of continuations interacts with data
// on the stack such as the variable `x`. In this example the copy
// happens after the variable `x` is created.
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test the way in which copying of continuations interacts with data
// on the stack such as the variable `x`. In this example the copy
// happens before the variable `x` is created, so each continuation
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test that the read from x triggers an error because x is dead.
// This test also demonstrates how by-reference free-variable capture
// is dangerous and can happen inside continuations.
@@ -1,2 +1,2 @@
RUNTIME ERROR: executable_semantics/testdata/experimental_continuation9.carbon:12: undefined behavior: access to dead value 1
RUNTIME ERROR: executable_semantics/testdata/experimental_continuation9.carbon:14: undefined behavior: access to dead value 1
EXIT CODE: 255
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn f(x: i32) -> i32 {
return x - 1;
}
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// This tests the call-by-value aspect of parameter passing.
// This makes sure that when the value in `x` dies,
// it does not cause the value in `a` to also die.
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test multiple arguments
fn f(x: i32, y: i32) -> i32 {
return x + y;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test empty parameters and return type
fn f() { }
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn add(x: i32, y: i32) => x + y;
fn main() -> i32 {
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn f(x: i32, y: i32) -> i32 { return x + y; }
fn main() -> i32 {
+1 -1
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: executable_semantics/testdata/fun6_fail_type.carbon:10: type error in call
COMPILATION ERROR: executable_semantics/testdata/fun6_fail_type.carbon:12: type error in call
expected: (0 = i32, 1 = i32)
actual: (0 = (0 = i32, 1 = i32))
EXIT CODE: 255
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn f(x: i32, .d = y: i32) => x + y;
fn main() -> i32 {
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn f(x: i32, .d = y: i32, z: i32, .e = a: i32) => (x + y) - (z + a);
fn main() -> i32 {
+1 -1
View File
@@ -1,2 +1,2 @@
PROGRAM ERROR: executable_semantics/testdata/fun_named_params2.carbon:5: positional members must come before named members
PROGRAM ERROR: executable_semantics/testdata/fun_named_params2.carbon:7: positional members must come before named members
EXIT CODE: 255
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn f(x: i32) -> i32 {
if (x == 0) {
return x;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn add1(x: i32) -> i32 {
return x + 1;
}
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn id[T:! Type](x: T) -> T {
return x;
}
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn fst[T:! Type](x: T, y: T) -> T {
return x;
}
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn snd[T:! Type](x: i32, y: T) -> T {
return y;
}
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn apply[T:! Type, U:! Type](f: fnty (T) -> U, x: T) -> U {
return f(x);
}
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn fst[T:! Type](x: T, y: T) -> T {
return x;
}
@@ -1,4 +1,4 @@
COMPILATION ERROR: executable_semantics/testdata/generic_function_fail1.carbon:10: type error in argument deduction
COMPILATION ERROR: executable_semantics/testdata/generic_function_fail1.carbon:12: type error in argument deduction
expected: i32
actual: Bool
EXIT CODE: 255
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn id[T:! Type](x: i32) -> i32 {
return x;
}
@@ -1,2 +1,2 @@
COMPILATION ERROR: executable_semantics/testdata/generic_function_fail2.carbon:10: could not deduce type argument for type parameter T
COMPILATION ERROR: executable_semantics/testdata/generic_function_fail2.carbon:12: could not deduce type argument for type parameter T
EXIT CODE: 255
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn id[T:! Type](x: T) -> T {
return x + 0;
}
@@ -1,4 +1,4 @@
COMPILATION ERROR: executable_semantics/testdata/generic_function_fail3.carbon:6: type error in addition(1)
COMPILATION ERROR: executable_semantics/testdata/generic_function_fail3.carbon:8: type error in addition(1)
expected: i32
actual: T
EXIT CODE: 255
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn swap[T:! Type, U:! Type](tuple: (T, U)) -> (U, T) {
return (tuple[1], tuple[0]);
}
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn map[T:! Type](f: fnty (T) -> T, tuple: (T, T)) -> (T, T) {
return (f(tuple[0]), f(tuple[1]));
}
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test global variable initialization and read.
var zero: i32 = 0;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test that mutations to a global variable in one function is visible
// in another function.
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test type checking of global variable. Error expected.
var flag: i32 = true;
+1 -1
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: executable_semantics/testdata/global_variable3.carbon:7: type error in initializer of variable
COMPILATION ERROR: executable_semantics/testdata/global_variable3.carbon:9: type error in initializer of variable
expected: i32
actual: Bool
EXIT CODE: 255
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test mutation of a global variable.
var zero: i32 = 1;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test overshadowing of global variable.
var x: i32 = 1;
+1 -1
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: executable_semantics/testdata/global_variable5.carbon:10: type error in return
COMPILATION ERROR: executable_semantics/testdata/global_variable5.carbon:12: type error in return
expected: ()
actual: i32
EXIT CODE: 255
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test a global variable depending on another global.
var x: i32 = 0;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test a global variable depending on a function.
fn f() -> i32 {
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
// Test that a global variable may not depend on a later global.
// Error expected.
+1 -1
View File
@@ -1,2 +1,2 @@
RUNTIME ERROR: executable_semantics/testdata/global_variable8.carbon:8: could not find `y`
RUNTIME ERROR: executable_semantics/testdata/global_variable8.carbon:10: could not find `y`
EXIT CODE: 255
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
if (0 == 1) {
return 1;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
if (0 == 1) {
return 1;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
if (0 == 1) {
return 1;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
if (0 == 1) {
return 1;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
if (0 == 0) {
if (0 == 1) {
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
if (1 == 1) {
return 0;
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn ReturnSecond(_: i32, x: i32) -> i32 {
return x;
}
+11
View File
@@ -0,0 +1,11 @@
// 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
package ExecutableSemanticsTest api;
fn main() -> i32 {
return 0;
}
import ExecutableSemanticsTest library "Nonexistent";
+2
View File
@@ -0,0 +1,2 @@
COMPILATION ERROR: executable_semantics/testdata/import_late.carbon:11: syntax error, unexpected IMPORT, expecting END_OF_FILE
EXIT CODE: 255
@@ -0,0 +1,11 @@
// 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
package ExecutableSemanticsTest api;
import Nonexistent;
fn main() -> i32 {
return 0;
}
@@ -0,0 +1 @@
result: 0
@@ -0,0 +1,11 @@
// 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
package ExecutableSemanticsTest api;
import ExecutableSemanticsTest library "Nonexistent";
fn main() -> i32 {
return 0;
}
@@ -0,0 +1 @@
result: 0
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var t: auto = 5;
match (t) {
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var t: auto = 5;
match (t) {
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var t: auto = 5;
match (t) {
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var t: auto = (1, 2, 3, 4);
match (t) {
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main () -> i32
{
var x: i32 = 0;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var x: i32 = 0;
match (x) {
+9
View File
@@ -0,0 +1,9 @@
// 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
package ExecutableSemanticsTest library "Foo" api;
fn main() -> i32 {
return 0;
}
+1
View File
@@ -0,0 +1 @@
result: 0
+7
View File
@@ -0,0 +1,7 @@
// 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
fn main() -> i32 {
return 0;
}
+2
View File
@@ -0,0 +1,2 @@
COMPILATION ERROR: executable_semantics/testdata/package_missing.carbon:5: syntax error, unexpected FN, expecting PACKAGE
EXIT CODE: 255
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var (x: auto, y: auto) = (2, 3);
return y - x - 1;
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
// error
x : i32;
+1 -1
View File
@@ -1,2 +1,2 @@
COMPILATION ERROR: executable_semantics/testdata/pattern_variable_fail.carbon:7: syntax error, unexpected COLON
COMPILATION ERROR: executable_semantics/testdata/pattern_variable_fail.carbon:9: syntax error, unexpected COLON
EXIT CODE: 255
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var _: auto = 1;
return 0;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var s: auto = "Hello world!\n";
Print(s);
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn main() -> i32 {
var t2: (.x = i32, .y = i32) = (.x = 2, .y = 5);
t2.y = 3;
+2
View File
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn F() -> auto {
return 0;
}
+1 -1
View File
@@ -1,2 +1,2 @@
COMPILATION ERROR: executable_semantics/testdata/return_auto.carbon:5: syntax error, unexpected AUTO
COMPILATION ERROR: executable_semantics/testdata/return_auto.carbon:7: syntax error, unexpected AUTO
EXIT CODE: 255
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn F() -> () {
return ();
}
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn F() {
return ();
}
@@ -1,2 +1,2 @@
COMPILATION ERROR: executable_semantics/testdata/return_empty_explicit_fail.carbon:6: return (); should not provide a return value, to match the function's signature.
COMPILATION ERROR: executable_semantics/testdata/return_empty_explicit_fail.carbon:8: return (); should not provide a return value, to match the function's signature.
EXIT CODE: 255
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn F() {
}
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn F() {
return;
}
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn F() -> () {
}
@@ -1,2 +1,2 @@
COMPILATION ERROR: executable_semantics/testdata/return_empty_implicit_fail1.carbon:6: control-flow reaches end of function that provides a `->` return type without reaching a return statement
COMPILATION ERROR: executable_semantics/testdata/return_empty_implicit_fail1.carbon:8: control-flow reaches end of function that provides a `->` return type without reaching a return statement
EXIT CODE: 255
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
package ExecutableSemanticsTest api;
fn F() -> () {
return;
}

Some files were not shown because too many files have changed in this diff Show More