mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 19:30:12 +01:00
I should emphasize that I am **completely cheating** here. This PR does not add support for actually _performing_ implicit conversions at run time, because the AST doesn't yet contain the necessary type information. At run time, code like `var p: Point = {.x = 1, .y = 2};` directly initializes the name `p` with the _struct_ value `{.x = 1, .y = 2}`; no object of type `Point` is actually created. I'm only getting away with this because we don't yet have any tests that can tell the difference.
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
26 lines
668 B
Plaintext
26 lines
668 B
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
|
|
//
|
|
// RUN: executable_semantics %s 2>&1 | \
|
|
// RUN: FileCheck --match-full-lines --allow-unused-prefixes=false %s
|
|
// RUN: executable_semantics --trace %s 2>&1 | \
|
|
// RUN: FileCheck --match-full-lines --allow-unused-prefixes %s
|
|
// AUTOUPDATE: executable_semantics %s
|
|
// CHECK: result: 0
|
|
|
|
package ExecutableSemanticsTest api;
|
|
|
|
class Point {
|
|
var x: i32;
|
|
var y: i32;
|
|
}
|
|
|
|
fn GetX(p: Point) -> i32 {
|
|
return p.x;
|
|
}
|
|
|
|
fn main() -> i32 {
|
|
return GetX({.x = 1, .y = 2}) - 1;
|
|
}
|