mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-28 18:34:54 +01:00
* Support `p->member`, rewriting it to `(*p).member` in the parser. This behavior is as described in https://github.com/carbon-language/carbon-lang/tree/trunk/docs/design#pointer-types: > `p->m` is syntactic sugar for `(*p).m`.
28 lines
631 B
Plaintext
28 lines
631 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
|
|
//
|
|
// AUTOUPDATE
|
|
// RUN: %{explorer-run}
|
|
// RUN: %{explorer-run-trace}
|
|
// CHECK:STDOUT: 1
|
|
// CHECK:STDOUT: 1
|
|
// CHECK:STDOUT: 1
|
|
// CHECK:STDOUT: 1
|
|
// CHECK:STDOUT: result: 0
|
|
|
|
package Foo api;
|
|
class X {
|
|
fn F[self: Self]() -> i32 { return self.n; }
|
|
var n: i32;
|
|
}
|
|
fn Main() -> i32 {
|
|
var v: X = {.n = 1};
|
|
let p: X* = &v;
|
|
Print("{0}", p->n);
|
|
Print("{0}", p->(X.n));
|
|
Print("{0}", p->F());
|
|
Print("{0}", p->(X.F)());
|
|
return 0;
|
|
}
|