Files
sakurac/tests/programs/aliases_satisfy_what_they_alias_1.sakura
T

16 lines
511 B
Plaintext
Raw Normal View History

2026-10-26 10:14:11 -05:00
import std::io;
trait same<T> { def same(&this, other: &T): bool; }
struct pt { var x: i64; }
def pt::same(&this, other: &pt): bool { return this.x == other.x; }
type point = pt;
type spot = point;
def check<T>(a: &T, b: &T): string {
if const T is same<T> { return a.same(b) ? "same" : "differ"; }
return "unknown";
}
def main(): void {
val a: point = pt { 1 };
val b: point = pt { 1 };
val c: spot = pt { 2 };
println($"{check::<pt>(&a, &b)} {check::<point>(&a, &b)} {check::<spot>(&c, &c)}");
}