Remove : from vars in exec semantics (#504)

Going through tests, funptr1.6c is the main spot I see a real change, I added parens to get around an issue parsing fnty.

Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
Jon Meow
2021-05-06 14:21:31 -07:00
committed by GitHub
co-authored by Geoff Romer
parent 56b47bcfa9
commit 05663633d3
61 changed files with 145 additions and 137 deletions
+2 -2
View File
@@ -5,9 +5,9 @@
// Test that assignment performs a copy and does not create an alias.
fn main() -> Int {
var Int: x = -1;
var Int x = -1;
{
var Int: y = 0;
var Int y = 0;
x = y;
// y dies here
}
+2 -2
View File
@@ -5,8 +5,8 @@
// Test that assignment performs a copy and does not create an alias.
fn main() -> Int {
var Int: x = 0;
var Int: y = x;
var Int x = 0;
var Int y = x;
x = 1;
return y;
}
+2 -2
View File
@@ -3,9 +3,9 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var Int: x = 0;
var Int x = 0;
{
var Int: x = 1;
var Int x = 1;
}
return x;
}
+1 -1
View File
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var Int: x = 0;
var Int x = 0;
{
// empty block
}
+1 -1
View File
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var Int: x = 2;
var Int x = 2;
while (true) {
if (x == 0)
break;
+7 -7
View File
@@ -9,23 +9,23 @@ choice Ints {
}
fn main() -> Int {
var auto: x = Ints.None();
var auto: y = Ints.One(42);
var auto: n = 0;
var auto x = Ints.None();
var auto y = Ints.One(42);
var auto n = 0;
match (y) {
case Ints.None =>
n = n + 2;
case Ints.One(auto: x) =>
case Ints.One(auto x) =>
n = x + 1 - 42;
case Ints.Two(auto: a, auto: b) =>
case Ints.Two(auto a, auto b) =>
n = 2;
}
match (x) {
case Ints.One(auto: x) =>
case Ints.One(auto x) =>
n = x + 2;
case Ints.None() =>
n = n - 1;
case Ints.Two(auto: x, auto: y) =>
case Ints.Two(auto x, auto y) =>
n = 5;
}
return n;
+1 -1
View File
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var auto: x = 2;
var auto x = 2;
while (not (x == 0)) {
x = x - 1;
continue;
@@ -5,7 +5,7 @@
// Test that creating a continuation doesn't do anything.
fn main() -> Int {
var Int: x = 0;
var Int x = 0;
__continuation k {
x = x + 1;
}
@@ -5,7 +5,7 @@
// Test creating and running a continuation.
fn main() -> Int {
var Int: x = 0;
var Int x = 0;
__continuation k {
x = x + 1;
}
@@ -6,7 +6,7 @@
// `__run`.
fn main() -> Int {
var Int: x = 0;
var Int x = 0;
__continuation k {
x = x + 1;
__await;
@@ -6,13 +6,13 @@
// continuation as `k1`.
fn main() -> Int {
var Int: x = 0;
var Int x = 0;
__continuation k1 {
x = x + 1;
__await;
x = x + 2;
}
var __Continuation: k2 = k1;
var __Continuation k2 = k1;
__run k1;
__run k2;
return x;
@@ -5,9 +5,9 @@
// Test access to block-scoped variables upon resuming a continuation.
fn main() -> Int {
var Int: y = 0;
var Int y = 0;
__continuation k {
var Int: x = 0;
var Int x = 0;
x = x + 1;
__await;
x = x + 2;
@@ -4,9 +4,9 @@
// Test recursive functions inside continuations.
var Int: current = 0;
var Int current = 0;
fn CountUpTo(Int: x) -> Int {
fn CountUpTo(Int x) -> Int {
if (x == 0) {
current = 0;
__await;
@@ -22,8 +22,8 @@ fn main() -> Int {
__continuation k {
CountUpTo(5);
}
var Int: sum = 0;
var Int: count = 5;
var Int sum = 0;
var Int count = 5;
while (not (count == 0)) {
__run k;
sum = sum + current;
@@ -6,18 +6,18 @@
// on the stack such as the variable `x`. In this example the copy
// happens after the variable `x` is created.
var Int: y = 0;
var Int y = 0;
fn main() -> Int {
__continuation k1 {
var Int: x = 0;
var Int x = 0;
x = x + 1;
__await;
x = x + 2;
y = x;
}
__run k1;
var __Continuation: k2 = k1;
var __Continuation k2 = k1;
__run k2;
return y;
}
@@ -7,16 +7,16 @@
// happens before the variable `x` is created, so each continuation
// creates a different `x`.
var Int: y = 0;
var Int y = 0;
fn main() -> Int {
__continuation k1 {
var Int: x = 0;
var Int x = 0;
x = x + 1;
__await;
y = x;
}
var __Continuation: k2 = k1;
var __Continuation k2 = k1;
__run k1;
__run k2;
__run k1;
@@ -7,15 +7,15 @@
// is dangerous and can happen inside continuations.
fn capture() -> __Continuation {
var Int: x = 1;
var Int x = 1;
__continuation k {
var Int: y = x;
var Int y = x;
}
return k;
}
fn main() -> Int {
var __Continuation: k = capture();
var __Continuation k = capture();
__run k; // error, lifetime of x is over
return 0;
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn f(Int: x) -> Int {
fn f(Int x) -> Int {
return x - 1;
}
+2 -2
View File
@@ -6,12 +6,12 @@
// This makes sure that when the value in `x` dies,
// it does not cause the value in `a` to also die.
fn f(Int: x) -> Int {
fn f(Int x) -> Int {
return 0;
}
fn main() -> Int {
var Int: a = 0; var Int: b = 1;
var Int a = 0; var Int b = 1;
f(a);
b = a;
return b;
+1 -1
View File
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// Test multiple arguments
fn f(Int: x, Int: y) -> Int {
fn f(Int x, Int y) -> Int {
return x + y;
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn add(Int: x, Int: y) => x + y;
fn add(Int x, Int y) => x + y;
fn main() -> Int {
return add(1, 2) - 3;
+2 -2
View File
@@ -2,10 +2,10 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn f(Int: x, Int: y) -> Int { return x + y; }
fn f(Int x, Int y) -> Int { return x + y; }
fn main() -> Int {
var (Int, Int): xy = (1, 2);
var (Int, Int) xy = (1, 2);
// should fail to type-check
return f(xy);
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn f(Int: x, .d = Int: y) => x + y;
fn f(Int x, .d = Int y) => x + y;
fn main() -> Int {
return f(1, .d = 2) - 3;
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn f(Int: x, .d = Int: y, Int: z, .e = Int: a) => (x + y) - (z + a);
fn f(Int x, .d = Int y, Int z, .e = Int a) => (x + y) - (z + a);
fn main() -> Int {
return 0;
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn f(Int: x) -> Int {
fn f(Int x) -> Int {
if (x == 0)
return x;
else
+2 -2
View File
@@ -2,11 +2,11 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn add1(Int: x) -> Int {
fn add1(Int x) -> Int {
return x + 1;
}
fn main() -> Int {
var fnty(Int)->Int: f = add1;
var (fnty(Int)->Int) f = add1;
return f(-1);
}
+1 -1
View File
@@ -4,7 +4,7 @@
// Test global variable initialization and read.
var Int: zero = 0;
var Int zero = 0;
fn main() -> Int {
return zero;
+1 -1
View File
@@ -5,7 +5,7 @@
// Test that mutations to a global variable in one function is visible
// in another function.
var Int: flag = 1;
var Int flag = 1;
fn flipFlag() -> () {
flag = 0;
+1 -1
View File
@@ -4,7 +4,7 @@
// Test type checking of global variable. Error expected.
var Int: flag = true;
var Int flag = true;
fn main() -> Int {
return 0;
+1 -1
View File
@@ -4,7 +4,7 @@
// Test mutation of a global variable.
var Int: zero = 1;
var Int zero = 1;
fn main() -> Int {
zero = 0;
+2 -2
View File
@@ -4,9 +4,9 @@
// Test overshadowing of global variable.
var Int: x = 1;
var Int x = 1;
fn identity(Int: x) {
fn identity(Int x) {
return x;
}
+2 -2
View File
@@ -4,9 +4,9 @@
// Test a global variable depending on another global.
var Int: x = 0;
var Int x = 0;
var Int: y = x;
var Int y = x;
fn main() -> Int {
return y;
+1 -1
View File
@@ -8,7 +8,7 @@ fn f() -> Int {
return 0;
}
var Int: y = f();
var Int y = f();
fn main() -> Int {
return y;
+2 -2
View File
@@ -5,9 +5,9 @@
// Test that a global variable may not depend on a later global.
// Error expected.
var Int: x = y;
var Int x = y;
var Int: y = 0;
var Int y = 0;
fn main() -> Int {
return x;
+2 -2
View File
@@ -3,9 +3,9 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var auto: t = 5;
var auto t = 5;
match (t) {
case Int: x =>
case Int x =>
return x - 5;
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var auto: t = 5;
var auto t = 5;
match (t) {
case 5 =>
return 0;
+1 -1
View File
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var auto: t = 5;
var auto t = 5;
match (t) {
case 3 =>
return -1;
+4 -4
View File
@@ -3,14 +3,14 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var auto: t = fnty (Int,Int);
var Int: x = 0;
var auto t = fnty (Int,Int);
var Int x = 0;
match (t) {
case Type: z =>
case Type z =>
x = x + 1;
}
match (t) {
case fnty(Type: a,Type: b) =>
case fnty(Type a,Type b) =>
x = x - 1;
}
return x;
+1 -1
View File
@@ -4,6 +4,6 @@
fn main () -> Int
{
var Int: x = 0;
var Int x = 0;
return x;
}
+1 -1
View File
@@ -3,6 +3,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var (auto: x, auto: y) = (2, 3);
var (auto x, auto y) = (2, 3);
return y - x - 1;
}
+1 -1
View File
@@ -4,6 +4,6 @@
fn main() -> Int {
// error
Int : x;
Int x;
return 1;
}
+1 -1
View File
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var (.x = Int, .y = Int): t2 = (.x = 2, .y = 5);
var (.x = Int, .y = Int) t2 = (.x = 2, .y = 5);
t2.y = 3;
return t2.y - t2.x - 1; // 3 - 2 - 1
}
+3 -3
View File
@@ -3,11 +3,11 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var Int: x;
var Int: y;
var Int x;
var Int y;
}
fn main() -> Int {
var auto: p = Point(.x = 1, .y = 2);
var auto p = Point(.x = 1, .y = 2);
return p.y - p.x - 1;
}
+4 -4
View File
@@ -3,13 +3,13 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var Int: x;
var Int: y;
var Int x;
var Int y;
}
fn main() -> Int {
var auto: p1 = Point(.x = 1, .y = 2);
var auto: p2 = p1;
var auto p1 = Point(.x = 1, .y = 2);
var auto p2 = p1;
p2.x = 3;
return p1.x - 1;
}
+2 -2
View File
@@ -3,8 +3,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var Int: x;
var Int: y;
var Int x;
var Int y;
}
fn main() -> Int {
+2 -2
View File
@@ -3,8 +3,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var Int: x = (1);
var (Int,Int): t2 = (5, 2);
var Int x = (1);
var (Int,Int) t2 = (5, 2);
t2[0] = 3;
return t2[0] - t2[1] - x;
}
+2 -2
View File
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var (Int,): t1 = (5,);
var (Int, Int): t2 = (2, 3,);
var (Int,) t1 = (5,);
var (Int, Int) t2 = (2, 3,);
return t1[0] - t2[0] - t2[1];
}
+1 -1
View File
@@ -3,6 +3,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var (Int, .x = Int): t = (3, .x = 2);
var (Int, .x = Int) t = (3, .x = 2);
return t.x + 1 - t[0];
}
+1 -1
View File
@@ -3,6 +3,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var auto: t = (.x = 2, 3);
var auto t = (.x = 2, 3);
return 0;
}
+1 -1
View File
@@ -5,6 +5,6 @@
// Test the that field order matters for tuples.
fn main() -> Int {
var (.x = Int, .y = Int): t = (.y = 2, .x = 3);
var (.x = Int, .y = Int) t = (.y = 2, .x = 3);
return 0;
}
+2 -2
View File
@@ -3,8 +3,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var auto: x = 0;
var auto: y = 1;
var auto x = 0;
var auto y = 1;
(x, y) = (5, -5);
return x + y;
}
+2 -2
View File
@@ -3,8 +3,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var (Int,Int): t1 = (5, 2);
var (Int,Int): t2 = (5, 2);
var (Int,Int) t1 = (5, 2);
var (Int,Int) t2 = (5, 2);
if (t1 == t2) {
return 0;
} else {
+2 -2
View File
@@ -3,8 +3,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var (Int,Int): t1 = (5, 2);
var (Int,Int): t2 = (5, 4);
var (Int,Int) t1 = (5, 2);
var (Int,Int) t2 = (5, 4);
if (t1 == t2) {
return 1;
} else {
+2 -2
View File
@@ -3,8 +3,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var (Int,Int): t1 = (5, 2);
var (Int,): t2 = (5,);
var (Int,Int) t1 = (5, 2);
var (Int,) t2 = (5,);
if (t1 == t2) {
return 1;
} else {
+2 -2
View File
@@ -3,9 +3,9 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var auto: t = (5, 2);
var auto t = (5, 2);
match (t) {
case (auto: a, auto: b) =>
case (auto a, auto b) =>
return a + b - 7;
}
}
+2 -2
View File
@@ -5,9 +5,9 @@
// Test matching with a mixture of positional and named fields.
fn main() -> Int {
var auto: t = (2, .x = 5);
var auto t = (2, .x = 5);
match (t) {
case (auto: a, .x = auto: b) =>
case (auto a, .x = auto b) =>
return a - b + 3;
}
}
+2 -2
View File
@@ -5,9 +5,9 @@
// Test matching of a tuple inside a tuple.
fn main() -> Int {
var auto: t = ((1,2),(3,4));
var auto t = ((1,2),(3,4));
match (t) {
case ((auto: a, auto: b), auto: c) =>
case ((auto a, auto b), auto c) =>
return a - b + c[0] - c[1] + 2;
}
}
+2 -2
View File
@@ -2,11 +2,11 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn Id(Type: t) => t;
fn Id(Type t) => t;
// Test non-trivial type expression in variable declaration statement.
fn main() -> Int {
var Id(Int): x = 0;
var Id(Int) x = 0;
return x;
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn Id(Type: t) => t;
fn Id(Type t) => t;
// Test non-trivial type expression in return type.
+2 -2
View File
@@ -2,11 +2,11 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn Id(Type: t) => t;
fn Id(Type t) => t;
// Test non-trivial type expression in parameter type.
fn f(Id(Int): x) -> Int {
fn f(Id(Int) x) -> Int {
return x;
}
+1 -1
View File
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var auto: x = 2;
var auto x = 2;
while (not (x == 0))
x = x - 1;
return x;