mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 22:02:51 +01:00
Verify that provision/omission of return types matches (#717)
This is finishing #678
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
var flag: i32 = 1;
|
||||
|
||||
fn flipFlag() -> () {
|
||||
fn flipFlag() {
|
||||
flag = 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
|
||||
|
||||
fn F() -> auto {
|
||||
return 0;
|
||||
}
|
||||
|
||||
fn main() -> i32 {
|
||||
return F();
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user