mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 08:01:05 +01:00
Add support for return; (#678)
This creates a ReturnExpression. A separate change should enforce that an implicit return of `()` is only allowed in functions that have an implicit return type of `()`, and I think the structure taken here should ease that.
This commit is contained in:
@@ -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() -> Int {
|
||||
F();
|
||||
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
|
||||
|
||||
fn F() {
|
||||
}
|
||||
|
||||
fn main() -> Int {
|
||||
F();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
result: 0
|
||||
@@ -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() -> Int {
|
||||
F();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
result: 0
|
||||
Reference in New Issue
Block a user