Move Int parsing to i32 for #543 (#700)

Note this doesn't support other sizes or types, it just errors on them.

Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
Jon Meow
2021-08-05 09:34:12 -07:00
committed by GitHub
co-authored by Geoff Romer
parent 7e91fbc276
commit 2620ba066d
100 changed files with 212 additions and 202 deletions
+3 -3
View File
@@ -4,10 +4,10 @@
// Test that assignment performs a copy and does not create an alias.
fn main() -> Int {
var x: Int = -1;
fn main() -> i32 {
var x: i32 = -1;
{
var y: Int = 0;
var y: i32 = 0;
x = y;
// y dies here
}
+3 -3
View File
@@ -4,9 +4,9 @@
// Test that assignment performs a copy and does not create an alias.
fn main() -> Int {
var x: Int = 0;
var y: Int = x;
fn main() -> i32 {
var x: i32 = 0;
var y: i32 = x;
x = 1;
return y;
}
+3 -3
View File
@@ -2,10 +2,10 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var x: Int = 0;
fn main() -> i32 {
var x: i32 = 0;
{
var x: Int = 1;
var x: i32 = 1;
}
return x;
}
+2 -2
View File
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var x: Int = 0;
fn main() -> i32 {
var x: i32 = 0;
{
// empty block
}
+2 -2
View File
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var x: Int = 2;
fn main() -> i32 {
var x: i32 = 2;
while (true) {
if (x == 0) {
break;
+5 -5
View File
@@ -4,11 +4,11 @@
choice Ints {
None,
One(Int),
Two(Int,Int)
One(i32),
Two(i32,i32)
}
fn main() -> Int {
fn main() -> i32 {
var x: auto = Ints.None();
var y: auto = Ints.One(42);
var n: auto = 0;
@@ -34,6 +34,6 @@ fn main() -> Int {
// Test some alternate syntaxes
choice MoreInts {
None(),
One(Int),
Two(Int,Int),
One(i32),
Two(i32,i32),
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
var x: auto = 2;
while (not (x == 0)) {
x = x - 1;
@@ -4,8 +4,8 @@
// Test that creating a continuation doesn't do anything.
fn main() -> Int {
var x: Int = 0;
fn main() -> i32 {
var x: i32 = 0;
__continuation k {
x = x + 1;
}
@@ -4,8 +4,8 @@
// Test creating and running a continuation.
fn main() -> Int {
var x: Int = 0;
fn main() -> i32 {
var x: i32 = 0;
__continuation k {
x = x + 1;
}
@@ -5,8 +5,8 @@
// Test pausing a continuation with `__await` and restarting it with
// `__run`.
fn main() -> Int {
var x: Int = 0;
fn main() -> i32 {
var x: i32 = 0;
__continuation k {
x = x + 1;
__await;
@@ -5,8 +5,8 @@
// Assignment for continuations is shallow, so `k2` refers to the same
// continuation as `k1`.
fn main() -> Int {
var x: Int = 0;
fn main() -> i32 {
var x: i32 = 0;
__continuation k1 {
x = x + 1;
__await;
@@ -4,10 +4,10 @@
// Test access to block-scoped variables upon resuming a continuation.
fn main() -> Int {
var y: Int = 0;
fn main() -> i32 {
var y: i32 = 0;
__continuation k {
var x: Int = 0;
var x: i32 = 0;
x = x + 1;
__await;
x = x + 2;
@@ -4,9 +4,9 @@
// Test recursive functions inside continuations.
var current: Int = 0;
var current: i32 = 0;
fn CountUpTo(x: Int) -> Int {
fn CountUpTo(x: i32) -> i32 {
if (x == 0) {
current = 0;
__await;
@@ -18,12 +18,12 @@ fn CountUpTo(x: Int) -> Int {
}
}
fn main() -> Int {
fn main() -> i32 {
__continuation k {
CountUpTo(5);
}
var sum: Int = 0;
var count: Int = 5;
var sum: i32 = 0;
var count: i32 = 5;
while (not (count == 0)) {
__run k;
sum = sum + current;
@@ -6,11 +6,11 @@
// on the stack such as the variable `x`. In this example the copy
// happens after the variable `x` is created.
var y: Int = 0;
var y: i32 = 0;
fn main() -> Int {
fn main() -> i32 {
__continuation k1 {
var x: Int = 0;
var x: i32 = 0;
x = x + 1;
__await;
x = x + 2;
@@ -7,11 +7,11 @@
// happens before the variable `x` is created, so each continuation
// creates a different `x`.
var y: Int = 0;
var y: i32 = 0;
fn main() -> Int {
fn main() -> i32 {
__continuation k1 {
var x: Int = 0;
var x: i32 = 0;
x = x + 1;
__await;
y = x;
@@ -7,14 +7,14 @@
// is dangerous and can happen inside continuations.
fn capture() -> __Continuation {
var x: Int = 1;
var x: i32 = 1;
__continuation k {
var y: Int = x;
var y: i32 = x;
}
return k;
}
fn main() -> Int {
fn main() -> i32 {
var k: __Continuation = capture();
__run k; // error, lifetime of x is over
return 0;
+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(x: Int) -> Int {
fn f(x: i32) -> i32 {
return x - 1;
}
fn main() -> Int {
fn main() -> i32 {
return f(1);
}
+3 -3
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(x: Int) -> Int {
fn f(x: i32) -> i32 {
return 0;
}
fn main() -> Int {
var a: Int = 0; var b: Int = 1;
fn main() -> i32 {
var a: i32 = 0; var b: i32 = 1;
f(a);
b = a;
return b;
+2 -2
View File
@@ -3,10 +3,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// Test multiple arguments
fn f(x: Int, y: Int) -> Int {
fn f(x: i32, y: i32) -> i32 {
return x + y;
}
fn main() -> Int {
fn main() -> i32 {
return f(2,3) - 5;
}
+1 -1
View File
@@ -5,7 +5,7 @@
// Test empty parameters and return type
fn f() { }
fn main() -> Int {
fn main() -> i32 {
f();
return 0;
}
+2 -2
View File
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn add(x: Int, y: Int) => x + y;
fn add(x: i32, y: i32) => x + y;
fn main() -> Int {
fn main() -> i32 {
return add(1, 2) - 3;
}
+3 -3
View File
@@ -2,10 +2,10 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn f(x: Int, y: Int) -> Int { return x + y; }
fn f(x: i32, y: i32) -> i32 { return x + y; }
fn main() -> Int {
var xy: (Int, Int) = (1, 2);
fn main() -> i32 {
var xy: (i32, i32) = (1, 2);
// should fail to type-check
return f(xy);
}
+2 -2
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: 10: type error in call
expected: (0 = Int, 1 = Int)
actual: (0 = (0 = Int, 1 = Int))
expected: (0 = i32, 1 = i32)
actual: (0 = (0 = i32, 1 = i32))
EXIT CODE: 255
+2 -2
View File
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn f(x: Int, .d = y: Int) => x + y;
fn f(x: i32, .d = y: i32) => x + y;
fn main() -> Int {
fn main() -> i32 {
return f(1, .d = 2) - 3;
}
+2 -2
View File
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn f(x: Int, .d = y: Int, z: Int, .e = a: Int) => (x + y) - (z + a);
fn f(x: i32, .d = y: i32, z: i32, .e = a: i32) => (x + y) - (z + a);
fn main() -> Int {
fn main() -> i32 {
return 0;
}
+2 -2
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn f(x: Int) -> Int {
fn f(x: i32) -> i32 {
if (x == 0) {
return x;
} else {
@@ -10,6 +10,6 @@ fn f(x: Int) -> Int {
}
}
fn main() -> Int {
fn main() -> i32 {
return f(2);
}
+3 -3
View File
@@ -2,11 +2,11 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn add1(x: Int) -> Int {
fn add1(x: i32) -> i32 {
return x + 1;
}
fn main() -> Int {
var f: fnty(Int)->Int = add1;
fn main() -> i32 {
var f: fnty(i32)->i32 = add1;
return f(-1);
}
+1 -1
View File
@@ -6,6 +6,6 @@ fn id[T:! Type](x: T) -> T {
return x;
}
fn main() -> Int {
fn main() -> i32 {
return id(0);
}
+1 -1
View File
@@ -6,6 +6,6 @@ fn fst[T:! Type](x: T, y: T) -> T {
return x;
}
fn main() -> Int {
fn main() -> i32 {
return fst(0, 1);
}
+2 -2
View File
@@ -2,10 +2,10 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn snd[T:! Type](x: Int, y: T) -> T {
fn snd[T:! Type](x: i32, y: T) -> T {
return y;
}
fn main() -> Int {
fn main() -> i32 {
return snd(0, 1);
}
@@ -6,7 +6,7 @@ fn apply[T:! Type, U:! Type](f: fnty (T) -> U, x: T) -> U {
return f(x);
}
fn positive(x: Bool) -> Int {
fn positive(x: Bool) -> i32 {
if (x) {
return 2;
} else {
@@ -14,6 +14,6 @@ fn positive(x: Bool) -> Int {
}
}
fn main() -> Int {
fn main() -> i32 {
return apply(positive, false);
}
@@ -6,6 +6,6 @@ fn fst[T:! Type](x: T, y: T) -> T {
return x;
}
fn main() -> Int {
fn main() -> i32 {
return fst(0, true);
}
@@ -1,4 +1,4 @@
COMPILATION ERROR: 10: type error in argument deduction
expected: Int
expected: i32
actual: Bool
EXIT CODE: 255
@@ -2,10 +2,10 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn id[T:! Type](x: Int) -> Int {
fn id[T:! Type](x: i32) -> i32 {
return x;
}
fn main() -> Int {
fn main() -> i32 {
return id(0);
}
@@ -6,6 +6,6 @@ fn id[T:! Type](x: T) -> T {
return x + 0;
}
fn main() -> Int {
fn main() -> i32 {
return id(0);
}
@@ -1,4 +1,4 @@
COMPILATION ERROR: 6: type error in addition(1)
expected: Int
expected: i32
actual: T
EXIT CODE: 255
+1 -1
View File
@@ -6,6 +6,6 @@ fn swap[T:! Type, U:! Type](tuple: (T, U)) -> (U, T) {
return (tuple[1], tuple[0]);
}
fn main() -> Int {
fn main() -> i32 {
return swap((0, true))[1];
}
@@ -6,8 +6,8 @@ fn map[T:! Type](f: fnty (T) -> T, tuple: (T, T)) -> (T, T) {
return (f(tuple[0]), f(tuple[1]));
}
fn inc(x: Int) -> Int { return x + 1; }
fn inc(x: i32) -> i32 { return x + 1; }
fn main() -> Int {
fn main() -> i32 {
return map(inc, (0, 2))[0];
}
+2 -2
View File
@@ -4,8 +4,8 @@
// Test global variable initialization and read.
var zero: Int = 0;
var zero: i32 = 0;
fn main() -> Int {
fn main() -> i32 {
return zero;
}
+2 -2
View File
@@ -5,13 +5,13 @@
// Test that mutations to a global variable in one function is visible
// in another function.
var flag: Int = 1;
var flag: i32 = 1;
fn flipFlag() -> () {
flag = 0;
}
fn main() -> Int {
fn main() -> i32 {
flipFlag();
return flag;
}
+2 -2
View File
@@ -4,8 +4,8 @@
// Test type checking of global variable. Error expected.
var flag: Int = true;
var flag: i32 = true;
fn main() -> Int {
fn main() -> i32 {
return 0;
}
+1 -1
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: 7: type error in initializer of variable
expected: Int
expected: i32
actual: Bool
EXIT CODE: 255
+2 -2
View File
@@ -4,9 +4,9 @@
// Test mutation of a global variable.
var zero: Int = 1;
var zero: i32 = 1;
fn main() -> Int {
fn main() -> i32 {
zero = 0;
return zero;
}
+3 -3
View File
@@ -4,12 +4,12 @@
// Test overshadowing of global variable.
var x: Int = 1;
var x: i32 = 1;
fn identity(x: Int) {
fn identity(x: i32) {
return x;
}
fn main() -> Int {
fn main() -> i32 {
return identity(0);
}
+1 -1
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: 10: type error in return
expected: ()
actual: Int
actual: i32
EXIT CODE: 255
+3 -3
View File
@@ -4,10 +4,10 @@
// Test a global variable depending on another global.
var x: Int = 0;
var x: i32 = 0;
var y: Int = x;
var y: i32 = x;
fn main() -> Int {
fn main() -> i32 {
return y;
}
+3 -3
View File
@@ -4,12 +4,12 @@
// Test a global variable depending on a function.
fn f() -> Int {
fn f() -> i32 {
return 0;
}
var y: Int = f();
var y: i32 = f();
fn main() -> Int {
fn main() -> i32 {
return y;
}
+3 -3
View File
@@ -5,10 +5,10 @@
// Test that a global variable may not depend on a later global.
// Error expected.
var x: Int = y;
var x: i32 = y;
var y: Int = 0;
var y: i32 = 0;
fn main() -> Int {
fn main() -> i32 {
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 main() -> Int {
fn main() -> i32 {
if (0 == 1) {
return 1;
} else {
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
if (0 == 1) {
return 1;
} else if (0 == 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 main() -> Int {
fn main() -> i32 {
if (0 == 1) {
return 1;
} else if (0 == 2) {
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
if (0 == 1) {
return 1;
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
if (0 == 0) {
if (0 == 1) {
return 1;
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
if (1 == 1) {
return 0;
}
+2 -2
View File
@@ -2,10 +2,10 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn ReturnSecond(_: Int, x: Int) -> Int {
fn ReturnSecond(_: i32, x: i32) -> i32 {
return x;
}
fn main() -> Int {
fn main() -> i32 {
return ReturnSecond(1, 0);
}
+2 -2
View File
@@ -2,10 +2,10 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
var t: auto = 5;
match (t) {
case x: Int =>
case x: i32 =>
return x - 5;
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
var t: auto = 5;
match (t) {
case 5 =>
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
var t: auto = 5;
match (t) {
case 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 main() -> Int {
fn main() -> i32 {
var t: auto = (1, 2, 3, 4);
match (t) {
case (_: Int, _: auto, x: Int, y: auto) =>
case (_: i32, _: auto, x: i32, y: auto) =>
return y - x - 1;
}
}
+2 -2
View File
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main () -> Int
fn main () -> i32
{
var x: Int = 0;
var x: i32 = 0;
return x;
}
+2 -2
View File
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var x: Int = 0;
fn main() -> i32 {
var x: i32 = 0;
match (x) {
case 1 =>
return 1;
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
var (x: auto, y: auto) = (2, 3);
return y - x - 1;
}
+2 -2
View File
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
// error
x : Int;
x : i32;
return 1;
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
var _: auto = 1;
return 0;
}
+2 -2
View File
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var t2: (.x = Int, .y = Int) = (.x = 2, .y = 5);
fn main() -> i32 {
var t2: (.x = i32, .y = i32) = (.x = 2, .y = 5);
t2.y = 3;
return t2.y - t2.x - 1; // 3 - 2 - 1
}
+1 -1
View File
@@ -6,7 +6,7 @@ fn F() -> () {
return ();
}
fn main() -> Int {
fn main() -> i32 {
F();
return 0;
}
@@ -5,7 +5,7 @@
fn F() {
}
fn main() -> Int {
fn main() -> i32 {
F();
return 0;
}
@@ -6,7 +6,7 @@ fn F() {
return;
}
fn main() -> Int {
fn main() -> i32 {
F();
return 0;
}
+4 -4
View File
@@ -3,14 +3,14 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// Never actually called, so this only tests typechecking and semantic analysis.
fn F(n: Int, p: Int*, q: Int***) -> Int* {
var a: Int = n * *p;
var b: Int = a*n;
fn F(n: i32, p: i32*, q: i32***) -> i32* {
var a: i32 = n * *p;
var b: i32 = a*n;
*p = b*(*p);
**q = p;
return **q;
}
fn main() -> Int {
fn main() -> i32 {
return 0;
}
+3 -3
View File
@@ -3,11 +3,11 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var x: Int;
var y: Int;
var x: i32;
var y: i32;
}
fn main() -> Int {
fn main() -> i32 {
var p: auto = Point(.x = 1, .y = 2);
return p.y - p.x - 1;
}
+3 -3
View File
@@ -3,11 +3,11 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var x: Int;
var y: Int;
var x: i32;
var y: i32;
}
fn main() -> Int {
fn main() -> i32 {
var p1: auto = Point(.x = 1, .y = 2);
var p2: auto = p1;
p2.x = 3;
+3 -3
View File
@@ -3,10 +3,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var x: Int;
var y: Int;
var x: i32;
var y: i32;
}
fn main() -> Int {
fn main() -> i32 {
return Point(.x = 1, .y = 2).x - 1;
}
@@ -3,10 +3,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var x: Int;
var y: Int;
var x: i32;
var y: i32;
}
fn main() -> Int {
fn main() -> i32 {
return Point(.x = 1, .y = 2).z - 1;
}
+3 -3
View File
@@ -3,10 +3,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var x: Int;
var y: Int;
var x: i32;
var y: i32;
}
fn main() -> Int {
fn main() -> i32 {
return Point(.x = 1, .z = 2).x - 1;
}
+2 -2
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: 11: type error in call
expected: (x = Int, y = Int)
actual: (x = Int, z = Int)
expected: (x = i32, y = i32)
actual: (x = i32, z = i32)
EXIT CODE: 255
+3 -3
View File
@@ -3,10 +3,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var x: Int;
var y: Int;
var x: i32;
var y: i32;
}
fn main() -> Int {
fn main() -> i32 {
return Point(.x = 1).x - 1;
}
+2 -2
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: 11: type error in call
expected: (x = Int, y = Int)
actual: (x = Int)
expected: (x = i32, y = i32)
actual: (x = i32)
EXIT CODE: 255
+3 -3
View File
@@ -2,9 +2,9 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var x: Int = (1);
var t2: (Int,Int) = (5, 2);
fn main() -> i32 {
var x: i32 = (1);
var t2: (i32,i32) = (5, 2);
t2[0] = 3;
return t2[0] - t2[1] - x;
}
+3 -3
View File
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var t1: (Int,) = (5,);
var t2: (Int, Int) = (2, 3,);
fn main() -> i32 {
var t1: (i32,) = (5,);
var t2: (i32, i32) = (2, 3,);
return t1[0] - t2[0] - t2[1];
}
+2 -2
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var t: (Int, .x = Int) = (3, .x = 2);
fn main() -> i32 {
var t: (i32, .x = i32) = (3, .x = 2);
return t.x + 1 - t[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 main() -> Int {
fn main() -> i32 {
var t: auto = (.x = 2, 3);
return 0;
}
+2 -2
View File
@@ -4,7 +4,7 @@
// Test the that field order matters for tuples.
fn main() -> Int {
var t: (.x = Int, .y = Int) = (.y = 2, .x = 3);
fn main() -> i32 {
var t: (.x = i32, .y = i32) = (.y = 2, .x = 3);
return 0;
}
+2 -2
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: 8: type error in pattern variable
expected: (x = Int, y = Int)
actual: (y = Int, x = Int)
expected: (x = i32, y = i32)
actual: (y = i32, x = i32)
EXIT CODE: 255
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
var x: auto = 0;
var y: auto = 1;
(x, y) = (5, -5);
+3 -3
View File
@@ -2,9 +2,9 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var t1: (Int,Int) = (5, 2);
var t2: (Int,Int) = (5, 2);
fn main() -> i32 {
var t1: (i32,i32) = (5, 2);
var t2: (i32,i32) = (5, 2);
if (t1 == t2) {
return 0;
} else {
+3 -3
View File
@@ -2,9 +2,9 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var t1: (Int,Int) = (5, 2);
var t2: (Int,Int) = (5, 4);
fn main() -> i32 {
var t1: (i32,i32) = (5, 2);
var t2: (i32,i32) = (5, 4);
if (t1 == t2) {
return 1;
} else {
+3 -3
View File
@@ -2,9 +2,9 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
var t1: (Int,Int) = (5, 2);
var t2: (Int,) = (5,);
fn main() -> i32 {
var t1: (i32,i32) = (5, 2);
var t2: (i32,) = (5,);
if (t1 == t2) {
return 1;
} else {
+2 -2
View File
@@ -1,4 +1,4 @@
COMPILATION ERROR: 8: type error in ==
expected: (0 = Int, 1 = Int)
actual: (0 = Int)
expected: (0 = i32, 1 = i32)
actual: (0 = i32)
EXIT CODE: 255
+1 -1
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
var t: auto = (5, 2);
match (t) {
case (a: auto, b: auto) =>
+1 -1
View File
@@ -4,7 +4,7 @@
// Test matching with a mixture of positional and named fields.
fn main() -> Int {
fn main() -> i32 {
var t: auto = (2, .x = 5);
match (t) {
case (a: auto, .x = b: auto) =>
+1 -1
View File
@@ -4,7 +4,7 @@
// Test matching of a tuple inside a tuple.
fn main() -> Int {
fn main() -> i32 {
var t: auto = ((1,2),(3,4));
match (t) {
case ((a: auto, b: auto), c: auto) =>
+2 -2
View File
@@ -6,7 +6,7 @@ fn Id(t: Type) => t;
// Test non-trivial type expression in variable declaration statement.
fn main() -> Int {
var x: Id(Int) = 0;
fn main() -> i32 {
var x: Id(i32) = 0;
return x;
}
+1 -1
View File
@@ -6,6 +6,6 @@ fn Id(t: Type) => t;
// Test non-trivial type expression in return type.
fn main() -> Id(Int) {
fn main() -> Id(i32) {
return 0;
}
+2 -2
View File
@@ -6,10 +6,10 @@ fn Id(t: Type) => t;
// Test non-trivial type expression in parameter type.
fn f(x: Id(Int)) -> Int {
fn f(x: Id(i32)) -> i32 {
return x;
}
fn main() -> Int {
fn main() -> i32 {
return f(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 main() -> Int {
fn main() -> i32 {
var x: auto = 2;
while (not (x == 0)) {
x = x - 1;
+1 -1
View File
@@ -2,6 +2,6 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
fn main() -> Int {
fn main() -> i32 {
return 0;
}