Verify that provision/omission of return types matches (#717)

This is finishing #678
This commit is contained in:
Jon Meow
2021-08-06 15:18:39 -07:00
committed by GitHub
parent 4b2346cfcd
commit 6164cdfd6d
13 changed files with 133 additions and 60 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
var flag: i32 = 1;
fn flipFlag() -> () {
fn flipFlag() {
flag = 0;
}
+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
fn F() -> auto {
return 0;
}
fn main() -> i32 {
return F();
}
+2
View File
@@ -0,0 +1,2 @@
COMPILATION ERROR: 5: syntax error, unexpected AUTO
EXIT CODE: 255
@@ -0,0 +1,12 @@
// 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 F() {
return ();
}
fn main() -> i32 {
F();
return 0;
}
@@ -0,0 +1,2 @@
COMPILATION ERROR: 6: return (); should not provide a return value, to match the function's signature.
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
fn F() -> () {
}
fn main() -> i32 {
F();
return 0;
}
@@ -0,0 +1,2 @@
COMPILATION ERROR: 6: control-flow reaches end of function that provides a `->` return type without reaching a return statement
EXIT CODE: 255
@@ -0,0 +1,12 @@
// 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 F() -> () {
return;
}
fn main() -> i32 {
F();
return 0;
}
@@ -0,0 +1,2 @@
COMPILATION ERROR: 6: return; should provide a return value, to match the function's signature.
EXIT CODE: 255