mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-22 02:36:39 +00:00
Adds `BindAlias` with a hybrid of `BindName` and `NameRef` semantics. I think it's slightly closer to `BindName` because it introduces a name, so I'm going more in that direction. This also matches the need for `bind_name_id` with imports on enclosing scopes. Note, only things that look like a name reference are being allowed on the RHS of `alias`. This includes builtins that look like name references, such as `bool`, but not ones that turn into values underneath, such as `false`.
39 lines
1.3 KiB
Plaintext
39 lines
1.3 KiB
Plaintext
// 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
|
|
//
|
|
// AUTOUPDATE
|
|
|
|
namespace NS;
|
|
alias NS.a = bool;
|
|
|
|
let b: NS.a = false;
|
|
|
|
fn F() -> NS.a {
|
|
return false;
|
|
}
|
|
|
|
// CHECK:STDOUT: --- in_namespace.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %.1: bool = bool_literal false [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace {.NS = %.loc7, .F = %F} [template]
|
|
// CHECK:STDOUT: %.loc7: <namespace> = namespace {.a = %a} [template]
|
|
// CHECK:STDOUT: %a: type = bind_alias a, bool [template = bool]
|
|
// CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, %.loc7 [template = %.loc7]
|
|
// CHECK:STDOUT: %a.ref: type = name_ref a, %a [template = bool]
|
|
// CHECK:STDOUT: %.loc10: bool = bool_literal false [template = constants.%.1]
|
|
// CHECK:STDOUT: %b: bool = bind_name b, %.loc10
|
|
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F() -> bool {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %.loc13: bool = bool_literal false [template = constants.%.1]
|
|
// CHECK:STDOUT: return %.loc13
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|