diff --git a/README.md b/README.md index 844777a86..1c7ec0149 100644 --- a/README.md +++ b/README.md @@ -78,15 +78,15 @@ fn main() { match io.read_file("settings.json") { Ok(content) -> match json.parse(content, Config) { Ok(cfg) -> println("loaded: {cfg.name}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } Err(io.NotFound(path)) -> println("no config at {path} — run `silt init` first") - Err(e) -> println("read error: {e.message()}") + Err(e) -> println("read error: {Error.message(e)}") } } ``` -Stdlib errors are typed enums — `IoError`, `JsonError`, `HttpError`, and so on — so `match` can fork on specific failures like `NotFound(path)` and still fall back to `.message()` for the long tail. +Stdlib errors are typed enums — `IoError`, `JsonError`, `HttpError`, and so on — so `match` can fork on specific failures like `NotFound(path)` and still fall back to `Error.message` for the long tail. ## HTTP @@ -129,9 +129,9 @@ fn main() { (http.POST, ["todos"]) -> match bytes.to_string(req.body) { Ok(text) -> match json.parse(text, Todo) { Ok(todo) -> reply(201, todo) - Err(e) -> reply(400, #{ "error": e.message() }) + Err(e) -> reply(400, #{ "error": Error.message(e) }) } - Err(e) -> reply(400, #{ "error": e.message() }) + Err(e) -> reply(400, #{ "error": Error.message(e) }) } _ -> reply(404, #{ "error": "Not found" }) } diff --git a/docs/concurrency.md b/docs/concurrency.md index 220b2ea5c..c463dbd3d 100644 --- a/docs/concurrency.md +++ b/docs/concurrency.md @@ -717,7 +717,7 @@ fn main() { Ok(Ok(contents)) -> println(contents) Ok(Err(e)) -> println("the read failed: {e}") Err(task.Timeout) -> println("the read took too long") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } ``` diff --git a/docs/getting-started.md b/docs/getting-started.md index 9e32f6160..589798632 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -166,7 +166,7 @@ fn read_head(path) { ``` Use `match` to handle the result. Every stdlib error enum (here `IoError`) implements the built-in -`Error` trait, so you can pattern-match on specific variants and fall back to `.message()` for +`Error` trait, so you can pattern-match on specific variants and fall back to `Error.message` for anything else: ```silt @@ -177,7 +177,7 @@ fn main() { match io.read_file("app.json") { Ok(content) -> println("loaded {string.length(content)} characters") Err(io.NotFound(path)) -> println("file does not exist: {path}") - Err(e) -> println("error: {e.message()}") + Err(e) -> println("error: {Error.message(e)}") } } ``` diff --git a/docs/language/bindings-and-functions.md b/docs/language/bindings-and-functions.md index 7b7f54b87..7ecca0c78 100644 --- a/docs/language/bindings-and-functions.md +++ b/docs/language/bindings-and-functions.md @@ -81,7 +81,7 @@ fn main() { let _ = task.spawn { -> println("in the background") } match io.write_file("out.txt", "data") { Ok(_) -> println("saved") - Err(e) -> println("not saved: {e.message()}") + Err(e) -> println("not saved: {Error.message(e)}") } } ``` @@ -185,9 +185,9 @@ What a `let`'s value can reach is decided by four rules: module's impls give that module's traits (and the builtin traits): a `let` that mentions another module's function is initialised after every `let` those methods read. -- **A method call on a value whose type is a bounded type variable - (`fn f(x: a) where a: Label { x.label() }`) reaches every impl of the - method in the module**, whichever value the call is given. +- **A call through a trait with a value whose type is a bounded type + variable (`fn f(x: a) where a: Label { Label.label(x) }`) reaches every + impl of the method in the module**, whichever value the call is given. - **A `let` that is a plain value runs nothing.** A plain value is a literal, a name, a closure, or a list, tuple, record, map, set or variant made of plain values. Such a `let` needs only the top-level @@ -216,7 +216,7 @@ A closure handed to a function is not a plain value: `let f = wrap({ n -> ... f(n - 1) ... })` runs `wrap`, which may call the closure. - **Showing a value reaches the `Display` impls of its parts.** - Interpolation, `println`, `string.from` and `.display()` call the + Interpolation, `println` and `string.from` call the `Display` impl written for each type the value is made of: its own, its fields', its type arguments'. A value of an unknown type (a type variable, an associated type such as `Self::Item`) may be of any diff --git a/docs/language/error-handling.md b/docs/language/error-handling.md index d0accafb1..63c00cc0c 100644 --- a/docs/language/error-handling.md +++ b/docs/language/error-handling.md @@ -36,7 +36,7 @@ catalog is in [`docs/stdlib/errors.md`](../stdlib/errors.md); hovering over an error type in your editor shows the same table. You can either pattern-match on a specific variant, or fall back to -`.message()` for a rendered string: +`Error.message` for a rendered string: ```silt import io @@ -47,15 +47,15 @@ fn main() { Ok(content) -> println("loaded {string.length(content)} bytes") Err(io.NotFound(path)) -> println("file does not exist: {path}") Err(io.PermissionDenied(path)) -> println("denied: {path}") - Err(e) -> println("error: {e.message()}") + Err(e) -> println("error: {Error.message(e)}") } } ``` Every stdlib error enum implements the built-in `Error` trait, which has `Display` as a supertrait and provides `message(self) -> String`. String -interpolation `"{e}"` and `e.message()` produce the same text — silt routes -the `Display` impl through `Error::message` for stdlib error enums so the two +interpolation `"{e}"` and `Error.message(e)` produce the same text — silt routes +the `Display` impl through `Error.message` for stdlib error enums so the two shapes never drift. ## The `?` Operator diff --git a/docs/language/generics.md b/docs/language/generics.md index 695896a5c..331652968 100644 --- a/docs/language/generics.md +++ b/docs/language/generics.md @@ -140,13 +140,13 @@ point to. Inside the function a type variable stands for a type the function does not know: the body must work for every type the caller may choose. It cannot treat an `a` as an `Int`, return a `b` where it promised an `a`, -or call a method no `where` clause promises: +or ask of it a trait no `where` clause promises: ```silt fn one(x: a) -> a { 1 } -- ERROR: expected a, got Int fn second(x: a, y: b) -> a { y } -- ERROR: expected a, got b -fn show(x: a) -> String { x.display() } -- ERROR: `a` has no trait bound -fn show(x: a) -> String where a: Display { x.display() } -- ok +fn show(x: a) -> String { "{x}" } -- ERROR: `a` is not known to implement Display +fn show(x: a) -> String where a: Display { "{x}" } -- ok ``` An annotation in the body that writes one of the signature's variables @@ -225,12 +225,12 @@ fn parse(body: String, type a) -> Result(a, DecodeError) where a: Parse { } fn try_from(x: a, type b) -> b where a: Convertible(b) { - x.convert() + Convertible.convert(x) } ``` Inside the body, the `type a` parameter doubles as a dispatch target for -trait methods. `a.default()` invokes the `default` method of whichever +the trait methods that make a value. `a.default()` invokes the `default` method of whichever `Default` impl matches the concrete type passed in — see [Trait methods on types](#trait-methods-on-types) below. `try_from` shows the companion pattern: a parameterized trait @@ -381,7 +381,7 @@ import list import string fn shout(items: List(a)) -> List(String) where a: Display { - items |> list.map { x -> x.display() |> string.to_upper } + items |> list.map { x -> "{x}" |> string.to_upper } } ``` @@ -399,7 +399,7 @@ type Box(a) { trait Display for Box(a) where a: Display { fn display(self) -> String { match self { - Box(inner) -> "Box({inner.display()})" + Box(inner) -> "Box({inner})" } } } @@ -442,9 +442,9 @@ trait HashTable(Fn(Int) -> Int) for OtherStore { ... } ``` Supertraits can also reference the enclosing trait's params. The args -flow automatically — a `where x: Child(Int)` constraint makes -`Parent`'s methods callable on `x` with Parent's own params bound to -the same `Int`: +flow automatically — a `where x: Child(Int)` constraint lets `x` be +given to `Parent`'s methods with Parent's own params bound to the same +`Int`: ```silt trait Parent(a) { @@ -456,7 +456,7 @@ trait Child(a): Parent(a) { } fn use_parent(x: b, type a) -> a where b: Child(a) { - x.parent_method() -- returns a, bound by Child's arg + Parent.parent_method(x) -- returns a, bound by Child's arg } ``` @@ -474,7 +474,7 @@ lowercase type variables bound elsewhere in the signature: ```silt fn try_from(x: a, type b) -> b where a: Convertible(b) { - x.convert() + Convertible.convert(x) } ``` @@ -494,7 +494,7 @@ supplied arguments when resolving method types at the call site. Constraints transitively include supertraits. Given a user-defined `Ordered` trait whose declaration names `Equal` as a supertrait (hypothetical user-defined trait, not built-in), a `where a: Ordered` -bound makes methods from `Equal` callable on `a` as well: +bound gives `a` what `Equal` gives as well: ```silt trait Ordered: Equal { @@ -502,8 +502,8 @@ trait Ordered: Equal { } fn sorted_unique(xs: List(a)) -> List(a) where a: Ordered { - -- Both a.less(b) (from Ordered) and a.equal(b) (from the - -- transitively-included Equal supertrait) are callable here. + -- Both Ordered.less(a, b) and a == b (from the transitively- + -- included Equal supertrait) work here. ... } ``` @@ -532,9 +532,10 @@ error. See [Built-in Traits](traits.md#built-in-traits). ### Trait methods on types -Some trait methods take no `self` and only return `Self` — constructors -like `Default::default()` or `Monoid::empty()`. To invoke these without -an instance, call them on a **type descriptor**: either a bare type +Some trait methods take no value of the type and only make one — +constructors like `default()` or `empty()`. A call through the trait +could not say which impl it means, so these are called on a **type +descriptor**: either a bare type name (`Int.default()`) or a `type a` parameter (`a.default()`): ```silt @@ -563,19 +564,21 @@ The rules: - **Dispatch is by the descriptor's carried type name.** At runtime the descriptor `Int` resolves to the `Default` impl for `Int`; `Todo` resolves to `Default for Todo`; etc. -- **The descriptor is a dispatch key, not an argument.** It doesn't - occupy a `self` slot. Method signatures that declare `Self` as a - parameter (e.g. `fn combine(a: Self, b: Self)`) receive only the - caller's explicit arguments. +- **The descriptor is a dispatch key, not an argument.** It occupies no + parameter of the method: `a.empty()` passes nothing. +- **A method that takes a value of the type is called through its + trait.** `Monoid.combine(x, y)` reaches the impl for the type of its + arguments; `a.combine(x, y)` and `Int.combine(1, 2)` are errors whose + help names that call. - **`where` constraints are required** for the generic path. Writing `fn f(type a) -> a { a.default() }` without `where a: Default` rejects at the call to `a.default()` — the compiler can't prove an impl exists. -- **A method without `self` is called on a type, never on a value.** - `x.default()` on a value `x: a` is an error that names the call to - write: `a.default()`, with a `type a` parameter. Nor is it a candidate - for a call on a value: with `where a: Foo, a: Bar`, where only `Bar`'s - `build` takes `self`, `x.build()` is `Bar`'s. +- **A method that makes a value is called on a type, never on a value + or through its trait.** `x.default()` on a value `x: a` is an error (a + dot after a value names a field) whose help names the call to write: + `a.default()`, with a `type a` parameter. `Default.default()` is an + error that says to call it on a type. - **Ambiguity across traits is rejected.** If both `Foo` and `Bar` declare a method `build` and `a` is constrained to `Foo + Bar`, calling `a.build()` errors with "ambiguous method 'build' on `type a`: @@ -800,7 +803,7 @@ trait Convert(Int) for String { } fn into(x: a, type b) -> b where a: Convert(b) { - x.convert() + Convert.convert(x) } ``` diff --git a/docs/language/loops-and-pipes.md b/docs/language/loops-and-pipes.md index 3113a33b1..51e55c893 100644 --- a/docs/language/loops-and-pipes.md +++ b/docs/language/loops-and-pipes.md @@ -16,9 +16,9 @@ let a = list.filter(xs, { x -> x > 0 }) let b = xs |> list.filter { x -> x > 0 } ``` -The right side is a call like any other, so the rule is the same when it -is a method call: the piped value is the first argument the call writes, -after the receiver. `5 |> acc.add()` is `acc.add(5)`. +The right side is a call like any other, so the rule is the same for a +call through a trait: `5 |> Greet.greet` is `Greet.greet(5)`, and +`5 |> Adder.add(3)` is `Adder.add(5, 3)`. Without pipes, function composition nests inside-out. With pipes, it reads top-to-bottom: @@ -92,8 +92,7 @@ println("{user.name} is {user.age}") -- field access in interpolation String interpolation automatically invokes the `Display` trait. User-defined types and the displayable builtins implement `Display` automatically; channels and function values are the exception — they do not implement -`Display`, so interpolating them is a compile error. No need to call -`.display()` explicitly. +`Display`, so interpolating them is a compile error. Escape literal braces with backslash: `"\{not interpolation}"`. diff --git a/docs/language/modules.md b/docs/language/modules.md index a51b92d11..2524ff12f 100644 --- a/docs/language/modules.md +++ b/docs/language/modules.md @@ -169,14 +169,11 @@ module `util`. A type whose name no other type of the program has prints bare: `Pt {x: 1}`. Two modules may also each declare a trait of one name, say `Show` with -a method `show`, and implement it for one type. A method call means the -method of the trait its module sees: a trait it declares, imports by -name, or reaches through a module it imports. A call that sees both -traits is an error at the call. The builtin traits (`Display`, -`Compare`, `Equal`, `Hash`, `Error`) are always seen: a trait of the -program with a method named `display` implemented for `Int` makes -`5.display()` ambiguous; call it through a `where` bound for the -trait. The structural traits of a type (`Equal`, `Hash`, `Compare`, +a method `show`, and implement it for one type. A call names the trait +it means, as it names any item: `a.Show.show(5)` and `b.Show.show(5)` +are two calls of two methods. A trait of the program with a method named +`display` implemented for `Int` is no `Display`: `Pretty.display(5)` calls +it, and interpolation still shows `5` structurally. The structural traits of a type (`Equal`, `Hash`, `Compare`, `Display` without a written impl) go by the builtin traits of its fields, whatever trait of the program has a method of the same name. @@ -208,8 +205,8 @@ fn caller() -> Int { ``` A builtin module follows the same rule: after `import list`, a binding named -`list` hides the module inside its scope: `list.map` there is a method call -on the binding, which a `List` value does not have. No warning is given; +`list` hides the module inside its scope: `list.map` there is a field of +the binding, which a `List` value does not have. No warning is given; rename the binding, or import the module under another name (`import list as l`), to reach both. diff --git a/docs/language/traits.md b/docs/language/traits.md index 97955a704..22a34bb73 100644 --- a/docs/language/traits.md +++ b/docs/language/traits.md @@ -32,10 +32,19 @@ trait Greet for Shape { } fn main() { - println(Circle(5.0).greet()) -- hi from a circle of radius 5.0 + println(Greet.greet(Circle(5.0))) -- hi from a circle of radius 5.0 } ``` +A method that takes a value of the implementing type (`self`, or a +parameter of type `Self`) is called through its trait, as a module's +function is: `Greet.greet(c)`, `c |> Greet.greet`, +`list.map(shapes, Greet.greet)`. The call reaches the impl for the type +of that argument. A trait of another module is named as its other items +are: `shapes.Area.area(s)` after `import shapes`, or `Area.area(s)` after +`import shapes.{ Area }`. A dot after a value always names a field (see +[A dot after a value](#a-dot-after-a-value)). + A trait declares complete signatures: every parameter but `self` has a type annotation, and a method declared without a return type returns `()`. An impl's method has the types its trait declares, with the impl's @@ -74,8 +83,8 @@ real built-in `Display` trait look identical and are shown in An impl gives a record type no method named like one of the record's fields, whether the impl writes the method or takes it as the trait's -default: `job.run(5)` on a record is always a call of the function its -field `run` holds. +default: `job.run(5)` calls the function the field `run` holds, and a +method of that name would read as the same thing. ```silt type Job { @@ -137,23 +146,23 @@ trait Printable: Display + Hash { ### Constraint expansion -Inside a `where a: Cmp2` body, methods from `Eq2` (the supertrait) -are also callable on `a`: +Inside a `where t: Cmp2` body, a value of type `t` is also given to the +methods of `Eq2` (the supertrait), each called through its own trait: ```silt fn check(a: t, b: t) -> Bool where t: Cmp2 { - -- a.eq2(b) works because Eq2 is a supertrait of Cmp2 - match a.eq2(b) { + -- Eq2.eq2(a, b) works because Eq2 is a supertrait of Cmp2 + match Eq2.eq2(a, b) { true -> true - false -> a.lt2(b) + false -> Cmp2.lt2(a, b) } } ``` The expansion is transitive: with `trait C: B { ... }` and -`trait B: A { ... }`, a `where x: C` constraint enables methods from -`A`, `B`, and `C` on `x`, and implementing `C` on a type requires impls -of `A`, `B`, and `C`. +`trait B: A { ... }`, a `where x: C` constraint lets `x` be given to the +methods of `A`, `B`, and `C`, and implementing `C` on a type requires +impls of `A`, `B`, and `C`. ### Errors @@ -214,8 +223,8 @@ trait Show for Item { } fn main() { - println(Item { v: 1 }.show()) -- default - println(Item { v: 1 }.debug()) -- item-debug + println(Show.show(Item { v: 1 })) -- default + println(Show.debug(Item { v: 1 })) -- item-debug } ``` @@ -238,8 +247,8 @@ trait Show for Item { } ``` -Default bodies can call other trait methods on `self`, including -abstract ones the impl is required to provide. Dispatch routes the call +Default bodies can call other methods of the trait with `self`, +including abstract ones the impl is required to provide. Dispatch routes the call to the impl's version, so the default acts as a template that specialises per impl: @@ -249,7 +258,7 @@ trait Describable { fn name(self) -> String -- the default uses name() fn greet(self) -> String { - "hi, {self.name()}" + "hi, {Describable.name(self)}" } } @@ -264,12 +273,12 @@ trait Describable for Person { } fn main() { - println(Person { who: "alice" }.greet()) -- hi, alice + println(Describable.greet(Person { who: "alice" })) -- hi, alice } ``` Defaults compose with supertraits: a default body may call a supertrait -method on `self`, and the obligation that the supertrait be implemented +method with `self`, and the obligation that the supertrait be implemented is enforced as usual. Defaults work on parameterized impl targets too — `trait X for Box(a) { }` @@ -343,8 +352,8 @@ instantiation only, name it with an alias (`type Ints = List(Int)`, ### Impl-level where clauses -To call a trait method on an impl-bound type variable, declare the -constraint on the **impl header** using a `where` clause. The constraint +To give a value of an impl-bound type variable to a trait's method, +declare the constraint on the **impl header** using a `where` clause. The constraint applies to every method in the impl and is also enforced at every call site — passing a `Box(v)` where `v`'s type does not implement the required trait is a compile-time error: @@ -367,18 +376,18 @@ trait Greet for Int { trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { - Box(inner) -> inner.greet() + Box(inner) -> Greet.greet(inner) } } } fn main() { - println(Box(5).greet()) -- int-greet + println(Greet.greet(Box(5))) -- int-greet } ``` -`Box("hello").greet()` is an error: type 'String' does not implement -trait 'Greet'. +`Greet.greet(Box("hello"))` is an error: type 'String' does not +implement trait 'Greet'. Multi-trait bounds use `+` (or comma-separated clauses) — identical to fn-level `where`: @@ -386,7 +395,7 @@ fn-level `where`: ```silt trait Greet for Box(a) where a: Greet + Loud { fn greet(self) -> String { - match self { Box(inner) -> "{inner.greet()}-{inner.loud()}" } + match self { Box(inner) -> "{Greet.greet(inner)}-{Loud.loud(inner)}" } } } @@ -403,14 +412,14 @@ impl's method has the signature its trait declares, `where` clause included: it may restate a bound the trait declares for the method or the header declares (or a supertrait of one), with the same trait arguments, and may not add one, because a call through the -trait (`fn f(x: t) where t: Greet { x.greet() }`) knows only the trait's +trait (`fn f(x: t) where t: Greet { Greet.greet(x) }`) knows only the trait's signature and the header: ```silt trait Greet for Box(a) { fn greet(self) -> String where a: Greet { match self { - Box(inner) -> inner.greet() + Box(inner) -> Greet.greet(inner) } } } @@ -437,7 +446,7 @@ trait Peek for Int { trait Peek for Cell(a) where a: Peek { fn peek(self) -> Int { - self.value.peek() + Peek.peek(self.value) } } ``` @@ -473,12 +482,14 @@ specification — including how trait parameters flow through `where` clauses and how multiple impls with different arguments coexist — lives in [Generics — Parameterized trait declarations](generics.md#parameterized-trait-declarations). -## Static Trait Methods +## Methods That Make a Value -Some trait methods take no `self` and only return `Self` — constructors like -`Default::default()` or `Monoid::empty()`. Invoke these by calling on a -**type descriptor**: either a bare type name (`Int.empty()`) or a `type a` -parameter inside a generic function (`a.empty()`): +Some trait methods take no value of the type and only make one — +constructors like `default()` or `empty()`. A call through the trait +could not say which impl it means, so these are called on a **type**: +either a bare type name (`Int.empty()`) or a `type a` parameter inside a +generic function (`a.empty()`). A method that takes a value of the type +is called through its trait (`Monoid.combine(2, 3)`), never on a type: ```silt trait Monoid { @@ -497,32 +508,34 @@ trait Monoid for Int { fn main() { let zero = Int.empty() -- concrete dispatch - let five = Int.combine(2, 3) + let five = Monoid.combine(2, 3) println("{zero} {five}") } ``` -A method without `self` is called on a type, never on a value: -`5.empty()` is an error that names the call to write (`Int.empty()`). -Nor is it ever a candidate for a call on a value, of any trait: where -another trait gives the type a method of the same name that takes -`self`, `x.m(..)` calls that one, with no ambiguity; a call on the type -(`T.m(..)`) has both. An impl writes the parameters its trait declares: -one that adds or drops `self` (or any other parameter) is an error at -the impl. +`5.empty()` is an error: a dot after a value names a field, and the +help names the call to write (`Int.empty()`). `Int.combine(2, 3)` is an +error too: `type 'Int' has no method 'combine'`, with the help to call +it as `Monoid.combine(x, ..)`. Through a type only the methods that make +a value are candidates: of two traits that give a type a method of one +name, one that makes a value and one that takes one, `T.m(..)` is the +first; two that make one are ambiguous. An impl writes the parameters +its trait declares: one that adds or drops `self` (or any other +parameter) is an error at the impl. -Dispatch is by the descriptor's carried type name — `Int.empty()` resolves -to the `Monoid` impl for `Int`. Inside a generic function with -`type a` and `where a: Monoid`, `a.empty()` dispatches to whichever impl -matches the concrete type passed in. See +Dispatch is by the type — `Int.empty()` resolves to the `Monoid` impl +for `Int`. Inside a generic function with `type a` and +`where a: Monoid`, `a.empty()` dispatches to whichever impl matches the +concrete type passed in. See [Generics — Trait methods on types](generics.md#trait-methods-on-types) for the full rules. ## Method References -Trait method names are first-class callable values: `TypeName.method` produces -a function you can pass directly to a higher-order combinator. This avoids -writing a one-line closure around `x.method()`: +A method named through its trait is a function value, as a module's +function is: `Trait.method` can be passed directly to a higher-order +combinator. Where the type of its argument is known the value is the +method of that impl; in generic code it finds the impl where it runs. ```silt import list @@ -531,39 +544,68 @@ type Celsius { c: Float, } -trait Display for Celsius { - fn display(self) -> String { +trait Describe { + fn describe(self) -> String +} + +trait Describe for Celsius { + fn describe(self) -> String { "{self.c}°C" } } fn main() { let temps = [Celsius { c: 20.0 }, Celsius { c: 25.5 }] - let rendered = list.map(temps, Celsius.display) + let rendered = list.map(temps, Describe.describe) list.each(rendered) { line -> println(line) } } ``` -`value.method` without a call is not a function: a method is called. -Write `Type.method`, or a closure, `{ x -> x.method() }`. +A method that makes a value is taken through its type +(`list.map(codes, AppError.from)`). + +## A dot after a value + +A dot after a value names a field, whatever methods traits declare: + +- `p.name` is the record's field; `r.f(..)` calls the function the field + `f` holds. +- In a function whose parameter has no annotation, `fn name_of(p) { + p.name }` takes any record with a field `name`. +- A trait's method is called through the trait: `fn g(x) { + Greet.greet(x) }` is `fn g(x: a) -> String where a: Greet`, the bound + coming from the trait the call names. + +A dot that names nothing is an error that says what the value's type +lacks, with the call to write where the name is a trait's method or a +function of the type's builtin module: + +```silt +import list -## Calls on a value of unknown type +trait Greet { + fn greet(self) -> String +} -In a function whose parameter has no annotation, `x.m(..)` and `x.f` are -decided by what is written, not by which names happen to exist: +trait Greet for Int { + fn greet(self) -> String { + "hi" + } +} -- `x.f` is a field: `fn name_of(p) { p.name }` takes any record with a - field `name`, whatever methods traits declare. -- `r.f(..)` on a record with a field `f` calls the function the field - holds: a record type has no method named like one of its fields. -- `x.m(..)` means the one trait in sight that declares a method `m` - taking `self`, and bounds `x` by it: `fn g(x) { x.greet() }` is - `fn g(x: a) -> String where a: Greet`. If no trait declares `m`, `x` is - a record whose field `m` holds a function. If several traits declare - an `m` that takes `self`, annotate `x`. +fn shown(n: Int, xs: List(Int)) { + println(n.frobnicate()) -- error: type 'Int' has no field 'frobnicate' + println(n.greet()) + -- error: type 'Int' has no field 'greet' + -- help: `greet` is a method of trait `Greet`: call it as `Greet.greet(n)` + println(xs.length()) + -- error: type 'List(Int)' has no field 'length' + -- help: `length` is a function of module `list`: call it as `list.length(xs)` +} +``` When the type of `x` is decided later in the same definition (a closure's -parameter by the call it is passed to), the call is checked against that +parameter by the call it is passed to), the field is checked against that type. ## Built-in Traits @@ -581,7 +623,7 @@ types arithmetic is on, `Int` and `Float`, and nothing else. | `Equal` | Equality comparison | by structure | no (an error) | | `Hash` | Hash value for maps/sets | by structure | no (an error) | | `Compare` | Order comparison; includes `Equal` | by structure | no (an error) | -| `Error` | Error reporting (`message()`) | types with an impl | yes | +| `Error` | Error reporting (`Error.message(e)`) | types with an impl | yes | | `Number` | `+ - * / %` and unary `-` | Int and Float only | no | Operators are these traits: `==` and `!=` need `Equal`, `<` `>` `<=` @@ -613,8 +655,7 @@ its fields in the order of their names). Write your own `Display` impl for a type of another module, or for a built-in type, is an error. A type that holds a function has no structural `Display`, and may be given a written one. There is one `Display`: `println`, `print`, interpolation, -`.display()`, `string.from` and a panic's message all show a value the -same way, and all use the impl you wrote, wherever a value of the type +`string.from` and a panic's message all show a value the same way, and all use the impl you wrote, wherever a value of the type is inside what is shown (`println([t])`, `"{Some(t)}"`, a field of a record). @@ -645,8 +686,10 @@ fields in the same order as `println`. `Equal`, `Hash` and `Compare` are **sealed**: they always come from a type's structure (a type gets them when every field -supports them), and `==`, `<`, `.equal()`, `.compare()`, `.hash()` and -map keys use exactly that structure. A record is ordered by its fields +supports them), and `==`, `<`, `Compare.compare`, `Hash.hash` and map +keys use exactly that structure. `Display`'s `display` and `Equal`'s +`equal` are not called by a program: interpolation and `string.from`, +and `==`, do what they would. A record is ordered by its fields in the order the type declares them, an enum by its variants in the order it declares them and then by their payloads. A hand-written `trait Equal for T`, `trait Compare for T` or @@ -727,14 +770,16 @@ type is the one named first, `Box`. Two things follow. A type has at most one impl of a trait in a whole program, and every module sees the same one: no two modules can each -write it. And the impl is there wherever it is called: a module that can -call a method of a trait on a value of a type imports the module of the -trait and the module of the type (directly, or through the modules it -imports), and one of those two holds the impl. A value is shown, and a -method answers, the same way in every module. +write it. And the impl is there wherever it is called: a call names the +trait, so its module is in the program, and so is the module of the +type of a value the call is given; one of those two holds the impl. A +value is shown, and a method answers, the same way in every module. -A module calls the methods of the traits whose modules it imports, -directly or through the modules it imports, and of the built-in traits. +A module calls a trait's methods through the trait's name, which it +names as any item: a trait it declares, one it imports by name +(`import shapes.{ Area }`), one of a module it imports +(`shapes.Area.area(s)`), or a built-in trait (`Compare`, `Hash`, +`Error`; `json.Encode` after `import json`). ### In the trait's module @@ -820,12 +865,12 @@ import list -- CORRECT: 'a' appears in the parameter annotation fn print_all(items: List(a)) where a: Display { - items |> list.each { item -> println(item.display()) } + items |> list.each { item -> println("{item}") } } -- ERROR: 'a' is unbound -- no annotation on x fn f(x) where a: Display { - println(x.display()) + println("{x}") } ``` diff --git a/docs/language/types.md b/docs/language/types.md index 89b30c7c6..095901e40 100644 --- a/docs/language/types.md +++ b/docs/language/types.md @@ -175,8 +175,8 @@ println(alice.name) -- Alice An anonymous record is shown as it is written, without a name, its fields in the order of their names: `println(alice)` prints -`{age: 30, name: Alice}`. A closed one has `==`, `.equal()`, `.hash()` -and `.display()` when its fields do, and no order (`<`, `.compare()`). +`{age: 30, name: Alice}`. A closed one has `Equal` (`==`), `Hash` and +`Display` when its fields do, and no order (`<`, `Compare.compare`). The type of `alice` is the structural type `{name: String, age: Int}`, which can also appear in any annotation: @@ -289,9 +289,8 @@ let r: {name: String, age: Int} = Person { name: "x", age: 3 } `time.Date { ... }`.) A value whose fields are read is a record, and `p.greet()` on it calls -a function held in a field `greet`. A method of a declared record is -not a field: a function that reads `p.name` and calls `p.greet()` needs -its parameter annotated, `p: Person`, to call the method. +a function held in a field `greet`. A method of a trait is not a field: +it is called through its trait, `Greet.greet(p)`. A row variable stands for the rest of a record's fields, not for a type, so the only bounds it takes are the traits a record has when its diff --git a/docs/proposals/error-from-trait.md b/docs/proposals/error-from-trait.md index e74a63cf7..2d44befce 100644 --- a/docs/proposals/error-from-trait.md +++ b/docs/proposals/error-from-trait.md @@ -228,9 +228,8 @@ trait IntoAppError for json.JsonError { } fn load_config(path: String) -> Result(Config, AppError) { - let raw = result.map_err(io.read_file(path), io.IoError.into_app_error)? - -- OR using a closure to make the conversion name visible on the value side: - let cfg = result.map_err(json.parse(raw, Config)) { e -> e.into_app_error() }? + let raw = result.map_err(io.read_file(path), IntoAppError.into_app_error)? + let cfg = result.map_err(json.parse(raw, Config), IntoAppError.into_app_error)? Ok(cfg) } ``` @@ -239,9 +238,6 @@ This **works in silt today** because dispatch is by `Self` (each source type has one impl, no collision). Drawbacks: - One `trait IntoX` per target AppError type — doesn't reuse. -- First-class method reference form (`IoError.into_app_error`) hits - the same limits as `AppError.from` when passed as a value, so the - closure form may still be needed at some call sites. Still ugly. But it's the best pattern available without compiler work. @@ -294,7 +290,7 @@ an unknown tail risk of adjacent generic-trait regressions. | Unified `SiltError` stdlib type | Loses the module-specific pattern-match granularity the typed errors just shipped. | | Polymorphic variants (OCaml-style) | Requires a structural-typing extension to silt's nominal type system. Out of scope. | | **One trait per source type** (`trait IntoAppError { fn into_app_error(self) -> AppError }`) | Implementable today. Rejected as the *proposal* design because it doesn't scale — one new trait per target AppError. But it's the right **available-today workaround** and is documented above. | -| **Inverted `trait IntoErr(target) for Source`** | Dispatches by Self. Works today for multi-source → one-target IF silt supports trait-param inference from target-type ascription (unverified). Rejected because call site becomes `io_err.into_err()` with target inferred from context — i.e. Rust's `.into()` with a different name, the very thing the proposal exists to reject. | +| **Inverted `trait IntoErr(target) for Source`** | Dispatches by Self. Works today for multi-source → one-target IF silt supports trait-param inference from target-type ascription (unverified). Rejected because call site becomes `IntoErr.into_err(io_err)` with target inferred from context — i.e. Rust's `.into()` with a different name, the very thing the proposal exists to reject. | ## Non-goals clarified diff --git a/docs/stdlib/bytes.md b/docs/stdlib/bytes.md index c8246a430..b8a13888c 100644 --- a/docs/stdlib/bytes.md +++ b/docs/stdlib/bytes.md @@ -66,7 +66,7 @@ fn main() { let greeting = bytes.concat_all([hello, space, world]) match bytes.to_string(greeting) { Ok(s) -> println(s) -- hello world - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } -- Slicing (half-open; an index past the end is the end) @@ -96,7 +96,7 @@ fn main() { Every fallible `bytes.*` call returns `Result(T, BytesError)`. The enum exposes these variants keyed by the structural failure; pattern-match -for granular handling or fall back to `e.message()`: +for granular handling or fall back to `Error.message(e)`: | Variant | Fields | Raised by | |---------|--------|-----------| diff --git a/docs/stdlib/channel-task.md b/docs/stdlib/channel-task.md index e3c91f92c..c04d242c3 100644 --- a/docs/stdlib/channel-task.md +++ b/docs/stdlib/channel-task.md @@ -583,7 +583,7 @@ fn main() { Ok(Ok(contents)) -> println(contents) Ok(Err(e)) -> println("the read failed: {e}") Err(task.Timeout) -> println("the read took too long") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } ``` diff --git a/docs/stdlib/encoding.md b/docs/stdlib/encoding.md index 2d6cc7931..604098626 100644 --- a/docs/stdlib/encoding.md +++ b/docs/stdlib/encoding.md @@ -70,7 +70,7 @@ fn main() { ## Errors The two decoders return `Result(_, EncodingError)`; the encoders are total -functions. `e.message()` (and `"{e}"`) is the text of the variant. +functions. `Error.message(e)` (and `"{e}"`) is the text of the variant. | Variant | Fields | Meaning | |---------|--------|---------| diff --git a/docs/stdlib/errors.md b/docs/stdlib/errors.md index 99d8fe672..406726941 100644 --- a/docs/stdlib/errors.md +++ b/docs/stdlib/errors.md @@ -10,8 +10,8 @@ Every fallible stdlib module declares its own typed error enum. Silt's `Result(T, ModuleError)` return shape lets user code pattern-match the failure modes directly instead of substring-matching on a `String` payload. Each enum implements the built-in `Error` trait, which -supertypes `Display` and provides a `message()` method so code that -just wants a rendered error can fall back to `"{e.message()}"`. +has `Display` as its supertrait and a method `message`, so code that +just wants a rendered error can fall back to `"{Error.message(e)}"`. ## Variant naming diff --git a/docs/stdlib/http.md b/docs/stdlib/http.md index d6bf5a9e7..55a5b3ae1 100644 --- a/docs/stdlib/http.md +++ b/docs/stdlib/http.md @@ -58,9 +58,9 @@ fn main() { match http.get("http://127.0.0.1:8080/") { Ok(resp) -> match bytes.to_string(resp.body) { Ok(text) -> println(text) - Err(e) -> println("the body is no text: {e.message()}") + Err(e) -> println("the body is no text: {Error.message(e)}") } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } ``` @@ -84,7 +84,7 @@ is there (DNS, connection, TLS, a timeout, a head that is no HTTP), and one after it: a body that is cut short (`ClosedEarly`), and a body that does not unpack or is larger than 10,000,000 bytes (`InvalidResponse`). A program for which a status is a failure looks at `resp.status`. -`HttpError` implements the built-in `Error` trait, so `e.message()` +`HttpError` implements the built-in `Error` trait, so `Error.message(e)` always yields a rendered string. | Variant | Fields | Meaning | @@ -144,7 +144,7 @@ fn main() { match http.get("https://api.github.com/users/torvalds") { Ok(resp) -> println("Status: {resp.status}, body length: {bytes.length(resp.body)}") Err(http.Timeout) -> println("timed out; retry later") - Err(e) -> println("Network error: {e.message()}") + Err(e) -> println("Network error: {Error.message(e)}") } } ``` @@ -425,9 +425,9 @@ fn main() { body: bytes.from_string(json.stringify(user)), headers: #{ "Content-Type": "application/json" }, } - Err(e) -> reply(400, e.message()) + Err(e) -> reply(400, Error.message(e)) } - Err(e) -> reply(400, e.message()) + Err(e) -> reply(400, Error.message(e)) } _ -> reply(404, "Not found") diff --git a/docs/stdlib/int-float.md b/docs/stdlib/int-float.md index 6eb1c1bec..1575857fb 100644 --- a/docs/stdlib/int-float.md +++ b/docs/stdlib/int-float.md @@ -103,7 +103,7 @@ int.parse(s: String) -> Result(Int, IntError) Parses a string as an integer. Leading/trailing whitespace is trimmed. Returns `Ok(n)` on success, `Err(IntError)` on failure — a typed enum with variants `Empty`, `InvalidDigit(offset)`, `Overflow`, `Underflow` and `Other(message)`. -Match on the variant to handle specific cases, or fall back to `e.message()` for +Match on the variant to handle specific cases, or fall back to `Error.message(e)` for a human-readable default. ```silt @@ -112,7 +112,7 @@ import int fn main() { match int.parse("42") { Ok(n) -> println(n) - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } -- Pattern-match on specific failure modes: @@ -345,7 +345,7 @@ import float fn main() { match float.parse("3.14") { Ok(f) -> println(f) - Err(e) -> println("error: {e.message()}") + Err(e) -> println("error: {Error.message(e)}") } } ``` diff --git a/docs/stdlib/io-fs.md b/docs/stdlib/io-fs.md index 54b2835d6..841960057 100644 --- a/docs/stdlib/io-fs.md +++ b/docs/stdlib/io-fs.md @@ -34,9 +34,9 @@ Every fallible `io` / `fs` function returns `Result(T, IoError)`. | `Other(msg)` | everything else | `IoError` implements the built-in `Error` trait, so every value exposes -`.message() -> String` for a human-readable summary. Most call sites +`Error.message(e) -> String` for a human-readable summary. Most call sites destructure specific variants when they need to branch (e.g. "create a -default when the file does not exist") and fall through to `.message()` +default when the file does not exist") and fall through to `Error.message` otherwise. See [stdlib errors](errors.md) for the shared `Error` trait. See also [bytes](bytes.md) for reading/writing binary data. @@ -101,7 +101,7 @@ fn main() { match io.read_file("data.txt") { Ok(contents) -> println(contents) Err(io.NotFound(path)) -> println("no such file: {path}") - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -126,7 +126,7 @@ fn main() { match io.read_line() { Ok(name) -> println("Hello, {name}!") Err(io.UnexpectedEof) -> println("(EOF)") - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -149,7 +149,7 @@ import io fn main() { match io.write_file("output.txt", "hello") { Ok(_) -> println("written") - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -328,7 +328,7 @@ import fs fn main() { match fs.copy("original.txt", "backup.txt") { Ok(_) -> println("copied") - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -410,7 +410,7 @@ import list fn main() { match fs.list_dir(".") { Ok(entries) -> list.each(entries) { name -> println(name) } - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -431,7 +431,7 @@ import fs fn main() { match fs.mkdir("output/reports") { Ok(_) -> println("directory created") - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -452,7 +452,7 @@ import fs fn main() { match fs.remove("temp.txt") { Ok(_) -> println("removed") - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -473,7 +473,7 @@ import fs fn main() { match fs.rename("old_name.txt", "new_name.txt") { Ok(_) -> println("renamed") - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -540,7 +540,7 @@ fn main() { None -> println("creation time not tracked on this filesystem") } } - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -584,7 +584,7 @@ import fs fn main() { match fs.read_link("link") { Ok(target) -> println("points at {target}") - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -624,7 +624,7 @@ import fs fn main() { match fs.walk("src") { Ok(paths) -> println("{paths}") - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -663,7 +663,7 @@ import fs fn main() { match fs.glob("src/**/*.silt") { Ok(files) -> println("{files}") - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` diff --git a/docs/stdlib/json.md b/docs/stdlib/json.md index 08f322b3c..187dba692 100644 --- a/docs/stdlib/json.md +++ b/docs/stdlib/json.md @@ -26,7 +26,7 @@ A document whose shape is not known in advance is read into a Every fallible `json.*` call returns `Result(T, JsonError)`. The `JsonError` enum has four variants you can pattern-match on, or fall back to -`e.message()` when you just want a rendered string (`trait Error for +`Error.message(e)` when you just want a rendered string (`trait Error for JsonError` is wired in): | Variant | Fields | Meaning | @@ -497,10 +497,11 @@ their names, `json.stringify(r)` in the order its type declares them), a are used wherever their types are in the value, at the top too: the counterpart of [`json.decode`](#jsondecode-1). An impl's `encode` uses it for the parts it writes; for its own value (`json.encode(self)`) it would call -itself without end. In a module that imports json, `x.encode()` is the -method of the trait: on a value whose type has a written impl it is what -the impl gives, as it gives it (`json.Float(1.0)` stays a `Float`); on any -other value it is `json.encode(x)`. +itself without end. `json.Encode.encode(x)` is the method of the trait, +called through it in a module that imports json: on a value whose type +has a written impl it is what the impl gives, as it gives it +(`json.Float(1.0)` stays a `Float`); on any other value it is +`json.encode(x)`. ```silt import json @@ -565,7 +566,7 @@ fn main() { let input = """{"name": "Alice", "age": 30}""" match json.parse(input, User) { Ok(user) -> println(user.name) - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -613,7 +614,7 @@ fn main() { let input = """[{"x": 1, "y": 2}, {"x": 3, "y": 4}]""" match json.parse_list(input, Point) { Ok(points) -> list.each(points) { p -> println("{p.x}, {p.y}") } - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -637,7 +638,7 @@ fn main() { let input = """{"x": 10, "y": 20}""" match json.parse_map(input, Int) { Ok(m) -> println(map.get(m, "x")) -- Some(10) - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` diff --git a/docs/stdlib/list.md b/docs/stdlib/list.md index c618e68a9..30e23e051 100644 --- a/docs/stdlib/list.md +++ b/docs/stdlib/list.md @@ -761,10 +761,10 @@ comes after `b`. The sort is stable: equal elements keep their order. import list fn main() { - println(list.sort_with([3, 1, 2]) { a, b -> b.compare(a) }) -- [3, 2, 1] + println(list.sort_with([3, 1, 2]) { a, b -> Compare.compare(b, a) }) -- [3, 2, 1] -- By the first of each pair only: (1, b) stays before (1, a). let pairs = [(2, "c"), (1, "b"), (1, "a")] - println(list.sort_with(pairs) { (x, _), (y, _) -> x.compare(y) }) -- [(1, b), (1, a), (2, c)] + println(list.sort_with(pairs) { (x, _), (y, _) -> Compare.compare(x, y) }) -- [(1, b), (1, a), (2, c)] } ``` diff --git a/docs/stdlib/postgres.md b/docs/stdlib/postgres.md index 9908fe4a8..da3427acd 100644 --- a/docs/stdlib/postgres.md +++ b/docs/stdlib/postgres.md @@ -153,7 +153,7 @@ the fields once per result, before the statement runs: `Err(TypeMismatch(column, field type, column type))`, say `TypeMismatch("id", "Int", "float8")`: the column's type decides, not its values (an `Int` field is not filled from a `float8` column even - where the value is `2.0`). Its `message()` says how to go on: + where the value is `2.0`). `Error.message(e)` says how to go on: ``postgres type mismatch on column `id`: expected Int, got float8; cast it in SQL, for example id::text``. A field that only a json document fills (a record, a map, a tuple, a type with a `json.Decode` @@ -464,11 +464,11 @@ fn main() { match users(db) { Ok(found) -> println("users: {found}") Err(postgres.TxnAborted) -> println("rolled back (transaction aborted, retry)") - Err(e) -> println("rolled back: {e.message()}") + Err(e) -> println("rolled back: {Error.message(e)}") } postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } ``` @@ -603,5 +603,5 @@ needed) are: | `Other(msg)` | `String` | Catch-all for shapes we can't classify | `PostgresError` implements the stdlib `Error` trait, so if you don't want -to pattern-match on variants you can always call `err.message()` to +to pattern-match on variants you can always call `Error.message(err)` to get a formatted user-friendly string. diff --git a/docs/stdlib/regex.md b/docs/stdlib/regex.md index ddc0f59e2..cd05544ea 100644 --- a/docs/stdlib/regex.md +++ b/docs/stdlib/regex.md @@ -20,7 +20,7 @@ fn main() { match regex.find("abc 123", "(") { Ok(found) -> println(found) Err(regex.InvalidPattern(why, at)) -> println("{why} at {at}") -- unclosed group at 0 - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } ``` @@ -71,7 +71,7 @@ fn main() { println(list.get(groups, 2)) -- Some(host) } Ok(None) -> println("no match") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } ``` @@ -123,7 +123,7 @@ fn main() { println(map.get(groups, "host")) -- Some(example) } Ok(None) -> println("no match") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } ``` diff --git a/docs/stdlib/result-option.md b/docs/stdlib/result-option.md index f80dbe6a0..9f52c25d4 100644 --- a/docs/stdlib/result-option.md +++ b/docs/stdlib/result-option.md @@ -155,7 +155,7 @@ fn load(path: String) -> Result(String, AppError) { fn main() { match load("missing.txt") { Ok(s) -> println(s) - Err(IoWrap(e)) -> println(e.message()) + Err(IoWrap(e)) -> println(Error.message(e)) } } ``` diff --git a/docs/stdlib/tcp.md b/docs/stdlib/tcp.md index a1afc3b3b..946330645 100644 --- a/docs/stdlib/tcp.md +++ b/docs/stdlib/tcp.md @@ -44,7 +44,7 @@ out the OS-specific noise. A variant says what failed: | `Timeout` | — | op exceeded its deadline | | `Other(msg)` | `String` | unclassified socket failure | -`TcpError` implements the built-in `Error` trait, so `e.message()` +`TcpError` implements the built-in `Error` trait, so `Error.message(e)` renders any variant as a string when you don't want to branch on it. ## Echo server example @@ -74,13 +74,13 @@ fn main() { loop(()) } Err(e) -> { - println("accept error: {e.message()}") + println("accept error: {Error.message(e)}") loop(()) } } } } - Err(e) -> println("listen error: {e.message()}") + Err(e) -> println("listen error: {Error.message(e)}") } } ``` @@ -202,7 +202,7 @@ fn main() { let _ = tcp.write(conn, bytes.from_string("hello")) tcp.close(conn) } - Err(e) -> println("connect_tls err: {e.message()}") + Err(e) -> println("connect_tls err: {Error.message(e)}") } } ``` @@ -248,7 +248,7 @@ fn serve(conn, cert, key) { let _ = tcp.write(tls, bytes.from_string("hello over TLS\n")) tcp.close(tls) } - Ok(Err(e)) -> println("handshake failed: {e.message()}") + Ok(Err(e)) -> println("handshake failed: {Error.message(e)}") Err(_) -> println("the client took too long") } } @@ -271,7 +271,7 @@ fn main() { let _ = task.spawn { -> serve(conn, cert, key) } loop(()) } - Err(e) -> println("accept failed: {e.message()}") + Err(e) -> println("accept failed: {Error.message(e)}") } } } @@ -325,7 +325,7 @@ fn main() { let _ = tcp.write(tls, bytes.from_string("hello, authenticated client")) tcp.close(tls) } - Err(e) -> println("mTLS handshake failed: {e.message()}") + Err(e) -> println("mTLS handshake failed: {Error.message(e)}") } } ``` diff --git a/docs/stdlib/time.md b/docs/stdlib/time.md index 58abed137..9b1e750a4 100644 --- a/docs/stdlib/time.md +++ b/docs/stdlib/time.md @@ -71,7 +71,7 @@ pattern that is no format are the structural failure modes: | `InvalidFormat(msg)` | `String` | the pattern is at fault, whatever the value or the text: an unknown specifier, or one the type has nothing for (a time of day for a `Date`, a time zone), in a format and in its parse alike; for a parse also fields that are not enough for the value (no time of day for a `DateTime`, no date, an empty pattern) | | `Other(msg)` | `String` | unclassified failure | -`TimeError` implements the built-in `Error` trait, so `e.message()` +`TimeError` implements the built-in `Error` trait, so `Error.message(e)` yields a rendered string when variant branching isn't needed. ## Summary diff --git a/docs/stdlib/toml.md b/docs/stdlib/toml.md index 77cd163ee..b097620a4 100644 --- a/docs/stdlib/toml.md +++ b/docs/stdlib/toml.md @@ -22,7 +22,7 @@ Parse TOML documents into typed silt values and serialize values to TOML. Every fallible `toml.*` call returns `Result(T, TomlError)`. The `TomlError` enum has four variants you can pattern-match on, or fall back to -`e.message()` when you just want a rendered string (`trait Error for +`Error.message(e)` when you just want a rendered string (`trait Error for TomlError` is wired in): | Variant | Fields | Meaning | @@ -230,7 +230,7 @@ fn main() { let input = "name = \"Alice\"\nage = 30\nactive = true\n" match toml.parse(input, User) { Ok(user) -> println(user.name) - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -264,7 +264,7 @@ fn main() { let input = "[[points]]\nx = 1\ny = 2\n\n[[points]]\nx = 3\ny = 4\n" match toml.parse_list(input, Point) { Ok(points) -> list.each(points) { p -> println("{p.x}, {p.y}") } - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -291,7 +291,7 @@ fn main() { let input = "x = 10\ny = 20\n" match toml.parse_map(input, Int) { Ok(m) -> println(map.get(m, "x")) -- Some(10) - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -336,7 +336,7 @@ fn main() { let data = #{ "name": "silt", "version": "1.0" } match toml.pretty(data) { Ok(s) -> println(s) - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` @@ -389,7 +389,7 @@ fn main() { let data = Package { name: "silt", version: "1.0" } match toml.stringify(data) { Ok(s) -> println(s) - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` diff --git a/docs/stdlib/uuid.md b/docs/stdlib/uuid.md index e876ed058..87d79d3e9 100644 --- a/docs/stdlib/uuid.md +++ b/docs/stdlib/uuid.md @@ -85,7 +85,7 @@ are total. It returns `Result(String, UuidError)`: | Variant | Fields | Meaning | |---------|--------|---------| -| `Invalid(String)` | why | the input is not a syntactically valid UUID; `e.message()` is `"invalid uuid: ..."` | +| `Invalid(String)` | why | the input is not a syntactically valid UUID; `Error.message(e)` is `"invalid uuid: ..."` | | `Other(String)` | message | unclassified failure | ## Notes diff --git a/docs/why-silt.md b/docs/why-silt.md index f2f0949bc..2dfc915f3 100644 --- a/docs/why-silt.md +++ b/docs/why-silt.md @@ -40,7 +40,7 @@ Three design commitments shape everything: task running in parallel can see a shared value without a lock. - Errors are values of a typed enum, not interface-typed strings. You pattern-match on specific variants (`Err(io.NotFound(path)) -> ...`) - and fall back to `.message()` for the long tail. + and fall back to `Error.message` for the long tail. - No `nil`. `Option(a)` is the only way to model absence, and the type checker makes you handle the `None` case. - You still get CSP with channels and cheap tasks. diff --git a/examples/birthdays.silt b/examples/birthdays.silt index 8525bff48..89cbb26ba 100644 --- a/examples/birthdays.silt +++ b/examples/birthdays.silt @@ -47,7 +47,7 @@ fn main() { ] """, Person) { Ok(p) -> p - Err(e) -> panic("Failed to parse people: {e.message()}") + Err(e) -> panic("Failed to parse people: {Error.message(e)}") } people |> list.each { p -> diff --git a/examples/concurrent_processor.silt b/examples/concurrent_processor.silt index 9854469c9..9c546126b 100644 --- a/examples/concurrent_processor.silt +++ b/examples/concurrent_processor.silt @@ -103,7 +103,7 @@ fn main() { } Err(err_info) -> { let (path, err) = err_info - println("[Worker {worker_id}] FAILED {path}: {err.message()}") + println("[Worker {worker_id}] FAILED {path}: {Error.message(err)}") loop(collected + 1, successes, failures + 1) } } diff --git a/examples/config_parser.silt b/examples/config_parser.silt index 08f4210ac..a83279981 100644 --- a/examples/config_parser.silt +++ b/examples/config_parser.silt @@ -124,7 +124,7 @@ fn main() { -- Read the config file let text = match io.read_file("examples/app.conf") { Ok(t) -> t - Err(e) -> return println("Error reading examples/app.conf: {e.message()}") + Err(e) -> return println("Error reading examples/app.conf: {Error.message(e)}") } println("=== Parsing config file ===") println("") diff --git a/examples/cross_module_errors.silt b/examples/cross_module_errors.silt index f27606704..d473e355e 100644 --- a/examples/cross_module_errors.silt +++ b/examples/cross_module_errors.silt @@ -25,7 +25,7 @@ type Config { -- Wrapper enum: one variant per module whose errors we want to -- surface, plus a Custom for ad-hoc domain errors. Silt's structural --- Display renders each variant cleanly; `.message()` falls through to +-- Display renders each variant cleanly; `Error.message` falls through to -- the underlying module's trait impl. type AppError { ConfigRead(io.IoError), @@ -57,11 +57,11 @@ fn main() { Err(e) -> match e { -- Granular handling per domain. ConfigRead(io.NotFound(path)) -> println("create a config at: {path}") - ConfigRead(inner) -> println("config file: {inner.message()}") - ConfigParse(inner) -> println("config JSON invalid: {inner.message()}") + ConfigRead(inner) -> println("config file: {Error.message(inner)}") + ConfigParse(inner) -> println("config JSON invalid: {Error.message(inner)}") ApiCall(http.Timeout) -> println("API timed out — retry later") - ApiCall(inner) -> println("API call failed: {inner.message()}") - ApiResponse(inner) -> println("API response invalid: {inner.message()}") + ApiCall(inner) -> println("API call failed: {Error.message(inner)}") + ApiResponse(inner) -> println("API response invalid: {Error.message(inner)}") Custom(msg) -> println("app: {msg}") } } diff --git a/examples/csv_analyzer.silt b/examples/csv_analyzer.silt index d24cf6b1e..81527b49f 100644 --- a/examples/csv_analyzer.silt +++ b/examples/csv_analyzer.silt @@ -89,7 +89,7 @@ fn main() { -- Read and parse CSV; bail out on IO errors with a rendered message. let content = match io.read_file("examples/data.csv") { Ok(text) -> text - Err(e) -> panic("Error reading data.csv: {e.message()}") + Err(e) -> panic("Error reading data.csv: {Error.message(e)}") } let lines = content |> string.split("\n") |> list.filter { l -> !string.is_empty(l) } let data_lines = lines |> list.drop(1) diff --git a/examples/diff_tool.silt b/examples/diff_tool.silt index 46c1ba232..c54660145 100644 --- a/examples/diff_tool.silt +++ b/examples/diff_tool.silt @@ -86,11 +86,11 @@ fn main() { -- Read both files, bailing out if either is missing. let old_content = match io.read_file("examples/data/original.txt") { Ok(content) -> content - Err(e) -> panic("Error reading original.txt: {e.message()}") + Err(e) -> panic("Error reading original.txt: {Error.message(e)}") } let new_content = match io.read_file("examples/data/modified.txt") { Ok(content) -> content - Err(e) -> panic("Error reading modified.txt: {e.message()}") + Err(e) -> panic("Error reading modified.txt: {Error.message(e)}") } -- Split into lines, filter out trailing empty line from final newline let old_lines = old_content |> string.split("\n") |> list.filter { l -> !string.is_empty(l) } diff --git a/examples/expr_eval.silt b/examples/expr_eval.silt index b75cd9e9b..0a8d1a403 100644 --- a/examples/expr_eval.silt +++ b/examples/expr_eval.silt @@ -20,9 +20,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -203,17 +203,17 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) let rpn_str = string.join(rpn, " ") println(" RPN: {rpn_str}") -- Round-trip: from_rpn(to_rpn(expr)) should equal original let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") println(" Depth: {depth(expr)}") @@ -223,10 +223,10 @@ fn main() { -- Demonstrate deep pattern matching println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -244,7 +244,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN println("\n=== From RPN ===\n") @@ -252,7 +252,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification println("\n=== Negative Pattern Simplification ===\n") @@ -264,7 +264,7 @@ fn main() { neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") } diff --git a/examples/http_client.silt b/examples/http_client.silt index 293028cf2..dfe27b0f4 100644 --- a/examples/http_client.silt +++ b/examples/http_client.silt @@ -16,20 +16,20 @@ type Repo { fn fetch_repos(user) { -- http.get returns HttpError, bytes.to_string BytesError and -- json.parse_list JsonError. Fold them into a single `String` channel - -- via `e.message()` so fetch_repos surfaces one uniform error type to + -- via `Error.message(e)` so fetch_repos surfaces one uniform error type to -- its caller. let resp = match http.get("https://api.github.com/users/{user}/repos") { Ok(r) -> r - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } -- The body is the bytes that arrived; JSON is text. let text = match bytes.to_string(resp.body) { Ok(text) -> text - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } match json.parse_list(text, Repo) { Ok(repos) -> Ok(repos) - Err(e) -> Err(e.message()) + Err(e) -> Err(Error.message(e)) } } diff --git a/examples/http_server.silt b/examples/http_server.silt index 615c9fc4d..7f58d8760 100644 --- a/examples/http_server.silt +++ b/examples/http_server.silt @@ -47,9 +47,9 @@ fn main() { (http.POST, ["todos"]) -> match bytes.to_string(req.body) { Ok(text) -> match json.parse(text, Todo) { Ok(todo) -> json_response(201, todo) - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } (http.GET, ["todos", id_str]) -> match int.parse(id_str) { Ok(id) -> json_response(200, Todo { id: id, title: "Todo {id}", done: false }) diff --git a/examples/json_time.silt b/examples/json_time.silt index dee86ea58..dd0005838 100644 --- a/examples/json_time.silt +++ b/examples/json_time.silt @@ -22,7 +22,7 @@ fn main() { -- Parse JSON with Date field let event = match json.parse("""{"name": "launch", "date": "2024-03-15"}""", Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("event: {event.name}") println("date: {event.date}") @@ -34,7 +34,7 @@ fn main() { Meeting, ) { Ok(m) -> m - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("meeting: {meeting.title} at {meeting.start}") -- Parse JSON with Time field @@ -43,7 +43,7 @@ fn main() { Schedule, ) { Ok(s) -> s - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("schedule: {sched.event} on {sched.date} at {sched.time}") -- Parse a list of events @@ -55,7 +55,7 @@ fn main() { ] """, Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } events |> list.each { e -> @@ -69,6 +69,6 @@ fn main() { let bad = json.parse("""{"name": "oops", "date": "not-a-date"}""", Event) match bad { Ok(e) -> println("bad date: parsed as {e.name}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } } diff --git a/examples/json_transform.silt b/examples/json_transform.silt index 5cc629200..b94a556f9 100644 --- a/examples/json_transform.silt +++ b/examples/json_transform.silt @@ -67,7 +67,7 @@ fn main() { -- Parse the JSON dataset let employees = match json.parse_list(employee_json, Employee) { Ok(emps) -> emps - Err(e) -> panic("Failed to parse employees: {e.message()}") + Err(e) -> panic("Failed to parse employees: {Error.message(e)}") } println("=== JSON Data Pipeline ===\n") -- 1. Group by department diff --git a/examples/kvstore.silt b/examples/kvstore.silt index ac93b3668..0fec3de1f 100644 --- a/examples/kvstore.silt +++ b/examples/kvstore.silt @@ -80,7 +80,7 @@ fn handle_save(store) { let json_str = json.stringify(store) match io.write_file(db_path, json_str) { Ok(_) -> println("OK - saved {map.length(store)} entries to {db_path}") - Err(e) -> println("Error saving: {e.message()}") + Err(e) -> println("Error saving: {Error.message(e)}") } store } @@ -88,7 +88,7 @@ fn handle_save(store) { fn handle_load() { match io.read_file(db_path) { Err(e) -> { - println("Error loading: {e.message()}") + println("Error loading: {Error.message(e)}") println("Starting with empty store.") #{} } @@ -98,7 +98,7 @@ fn handle_load() { loaded } Err(e) -> { - println("Error parsing JSON: {e.message()}") + println("Error parsing JSON: {Error.message(e)}") println("Starting with empty store.") #{} } diff --git a/examples/link_checker.silt b/examples/link_checker.silt index eac2b5461..c6f4ec644 100644 --- a/examples/link_checker.silt +++ b/examples/link_checker.silt @@ -23,7 +23,7 @@ fn main() { let content = match io.read_file(file_path) { Ok(c) -> c Err(e) -> { - println("Error reading file: {e.message()}") + println("Error reading file: {Error.message(e)}") return panic("Cannot continue without file") } } diff --git a/examples/pipeline.silt b/examples/pipeline.silt index b5caf26f9..cfd14fea3 100644 --- a/examples/pipeline.silt +++ b/examples/pipeline.silt @@ -137,7 +137,7 @@ fn main() { -- Read the log file; `return` in an Err arm bails out of main. let content = match io.read_file("examples/log.txt") { Ok(c) -> c - Err(e) -> return println("Error reading log file: {e.message()}") + Err(e) -> return println("Error reading log file: {Error.message(e)}") } let lines = content |> string.split("\n") |> list.filter { line -> !string.is_empty(line) } println("Loaded {list.length(lines)} log lines") diff --git a/examples/state_machine.silt b/examples/state_machine.silt index 02f2f742b..c2e5ca757 100644 --- a/examples/state_machine.silt +++ b/examples/state_machine.silt @@ -46,13 +46,13 @@ trait Display for Event { -- Print a labeled displayable value (uses where clause) fn print_labeled(label: String, value: a) where a: Display { - println("{label}: {value.display()}") + println("{label}: {value}") } -- Print a list of displayable items with a header (uses where clause) fn print_items(header: String, items: List(a)) where a: Display { println(header) - items |> list.each { item -> println(" - {item.display()}") } + items |> list.each { item -> println(" - {item}") } } -- Look up item info from inventory; returns (quantity, price) or None @@ -154,7 +154,7 @@ fn run_machine(events, initial_state, initial_inventory) { _ -> (state2, inventory2) } let (new_state, message, new_inv) = transition(state3, event, inventory3) - let new_log = list.append(log2, (step2, event.display(), state3, new_state, message)) + let new_log = list.append(log2, (step2, "{event}", state3, new_state, message)) (new_state, new_inv, step2 + 1, new_log) } let (_final_state, _final_inv, _step, log) = outcome @@ -206,7 +206,7 @@ fn main() { _ -> "{step}" } println("[{step_str}] Event: {event_str}") - println(" {old_state.display()} -> {new_state.display()}") + println(" {old_state} -> {new_state}") println(" >> {message}") println("") } diff --git a/examples/text_stats.silt b/examples/text_stats.silt index e26cc9995..4c9426c00 100644 --- a/examples/text_stats.silt +++ b/examples/text_stats.silt @@ -97,7 +97,7 @@ fn print_row(label, value) { fn main() { let filename = get_filename() match io.read_file(filename) { - Err(e) -> println("Error reading file '{filename}': {e.message()}") + Err(e) -> println("Error reading file '{filename}': {Error.message(e)}") Ok(content) -> { let lines = content |> string.split("\n") |> list.filter { l -> !string.is_empty(l) } let line_count = list.length(lines) diff --git a/examples/time_demo.silt b/examples/time_demo.silt index b6e10cc0c..18c776cb4 100644 --- a/examples/time_demo.silt +++ b/examples/time_demo.silt @@ -6,31 +6,31 @@ fn main() { let date = time.date(2024, 3, 15) match date { Ok(d) -> println("date: {d}") - Err(e) -> println("date error: {e.message()}") + Err(e) -> println("date error: {Error.message(e)}") } let bad_date = time.date(2024, 13, 1) match bad_date { Ok(d) -> println("bad date: {d}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } let t = time.time(14, 30, 0) match t { Ok(tm) -> println("time: {tm}") - Err(e) -> println("time error: {e.message()}") + Err(e) -> println("time error: {Error.message(e)}") } let bad_time = time.time(25, 0, 0) match bad_time { Ok(tm) -> println("bad time: {tm}") - Err(e) -> println("bad time: {e.message()}") + Err(e) -> println("bad time: {Error.message(e)}") } -- Compose date + time into datetime let d = match time.date(2024, 6, 15) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let tod = match time.time(9, 30, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt = time.datetime(d, tod) println("datetime: {dt}") @@ -42,11 +42,11 @@ fn main() { -- ── Formatting ────────────────────────────────────────────────────── let dt2_date = match time.date(2024, 12, 25) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let dt2_time = match time.time(18, 0, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt2 = time.datetime(dt2_date, dt2_time) println("formatted: {dt2 @@ -57,17 +57,17 @@ fn main() { let parsed = time.parse("2024-07-04 12:00:00", "%Y-%m-%d %H:%M:%S") match parsed { Ok(dt) -> println("parsed: {dt}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } let parsed_date = time.parse_date("2024-07-04", "%Y-%m-%d") match parsed_date { Ok(d) -> println("parsed date: {d}") - Err(e) -> println("parse date error: {e.message()}") + Err(e) -> println("parse date error: {Error.message(e)}") } let bad_parse = time.parse("not-a-date", "%Y-%m-%d %H:%M:%S") match bad_parse { Ok(dt) -> println("bad parse: {dt}") - Err(e) -> println("bad parse: {e.message()}") + Err(e) -> println("bad parse: {Error.message(e)}") } -- ── Date arithmetic ───────────────────────────────────────────────── let future = today |> time.add_days(90) @@ -77,13 +77,13 @@ fn main() { -- Month arithmetic with end-of-month clamping let jan31 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let feb_result = jan31 |> time.add_months(1) println("Jan 31 + 1 month = {feb_result}") let mar31 = match time.date(2024, 3, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let prev = mar31 |> time.add_months(-1) println("Mar 31 - 1 month = {prev}") @@ -114,11 +114,11 @@ fn main() { println("today is: {weekday}") let d_start = match time.date(2024, 1, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d_end = match time.date(2024, 12, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let days = time.days_between(d_start, d_end) println("days in 2024: {days}") @@ -130,11 +130,11 @@ fn main() { -- ── Comparison ────────────────────────────────────────────────────── let d1 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d2 = match time.date(2024, 2, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } println("Jan 31 < Feb 1: {d1 < d2}") println("Feb 1 > Jan 31: {d2 > d1}") diff --git a/examples/todo.silt b/examples/todo.silt index 5ebecb200..c129e55bf 100644 --- a/examples/todo.silt +++ b/examples/todo.silt @@ -56,7 +56,7 @@ fn save_todos(todos, path) { let content = json.stringify(todos) match io.write_file(path, content) { Ok(_) -> println(" Saved {list.length(todos)} todo(s) to {path}") - Err(e) -> println(" Error saving: {e.message()}") + Err(e) -> println(" Error saving: {Error.message(e)}") } } @@ -73,13 +73,13 @@ fn load_todos(path) { todos } Err(e) -> { - println(" Error parsing: {e.message()}") + println(" Error parsing: {Error.message(e)}") [] } } } Err(e) -> { - println(" Error loading: {e.message()}") + println(" Error loading: {Error.message(e)}") [] } } diff --git a/examples/trait_zoo.silt b/examples/trait_zoo.silt index 4095f4d4c..a7a0707d8 100644 --- a/examples/trait_zoo.silt +++ b/examples/trait_zoo.silt @@ -53,7 +53,7 @@ trait Display for Color { trait Display for Styled { fn display(self) -> String { match self { - Styled(shape, color) -> "{shape.display()} in {color.display()}" + Styled(shape, color) -> "{shape} in {color}" } } } @@ -98,7 +98,7 @@ trait Perimeter for Shape { -- Generic function with where clause fn describe(item: a) where a: Display { - item.display() + "{item}" } -- Format a float to 4 decimal places @@ -123,16 +123,16 @@ fn main() { shapes |> list.each { s -> println(" {describe(s)}") - println(" Area: {fmt(s.area())}") - println(" Perimeter: {fmt(s.perimeter())}") + println(" Area: {fmt(Area.area(s))}") + println(" Perimeter: {fmt(Perimeter.perimeter(s))}") } -- Sort shapes by area println("") println("-- Sorted by Area (ascending) --") - let sorted = shapes |> list.sort_by { s -> s.area() } - sorted |> list.each { s -> println(" {describe(s)} -> area = {fmt(s.area())}") } + let sorted = shapes |> list.sort_by { s -> Area.area(s) } + sorted |> list.each { s -> println(" {describe(s)} -> area = {fmt(Area.area(s))}") } -- Total area - let total_area = shapes |> list.map { s -> s.area() } |> list.fold(0.0) { acc, a -> acc + a } + let total_area = shapes |> list.map { s -> Area.area(s) } |> list.fold(0.0) { acc, a -> acc + a } println("") println("Total area: {fmt(total_area)}") -- Colors and styled shapes diff --git a/examples/traits.silt b/examples/traits.silt index e407961ea..21c785ec8 100644 --- a/examples/traits.silt +++ b/examples/traits.silt @@ -24,7 +24,7 @@ fn area(shape) { fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") - shapes |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + shapes |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } println("\nTotal area: {total}") let big = shapes |> list.filter { s -> area(s) > 10.0 } diff --git a/fuzz/corpus/fuzz_compiler/http_client.silt b/fuzz/corpus/fuzz_compiler/http_client.silt index 5ebaa97db..12a3ca26f 100644 --- a/fuzz/corpus/fuzz_compiler/http_client.silt +++ b/fuzz/corpus/fuzz_compiler/http_client.silt @@ -20,16 +20,16 @@ fn fetch_repos(user) { -- its caller. let resp = match http.get("https://api.github.com/users/{user}/repos") { Ok(r) -> r - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } -- The body is the bytes that arrived; JSON is text. let text = match bytes.to_string(resp.body) { Ok(text) -> text - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } match json.parse_list(text, Repo) { Ok(repos) -> Ok(repos) - Err(e) -> Err(e.message()) + Err(e) -> Err(Error.message(e)) } } diff --git a/fuzz/corpus/fuzz_compiler/http_server.silt b/fuzz/corpus/fuzz_compiler/http_server.silt index cff3c0e01..e9c253201 100644 --- a/fuzz/corpus/fuzz_compiler/http_server.silt +++ b/fuzz/corpus/fuzz_compiler/http_server.silt @@ -47,9 +47,9 @@ fn main() { (http.POST, ["todos"]) -> match bytes.to_string(req.body) { Ok(text) -> match json.parse(text, Todo) { Ok(todo) -> json_response(201, todo) - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } (http.GET, ["todos", id_str]) -> match int.parse(id_str) { Ok(id) -> json_response(200, Todo { id: id, title: "Todo {id}", done: false }) diff --git a/fuzz/corpus/fuzz_compiler/json_time.silt b/fuzz/corpus/fuzz_compiler/json_time.silt index 86ccc60c4..5c599757c 100644 --- a/fuzz/corpus/fuzz_compiler/json_time.silt +++ b/fuzz/corpus/fuzz_compiler/json_time.silt @@ -22,7 +22,7 @@ fn main() { -- Parse JSON with Date field let event = match json.parse("""{"name": "launch", "date": "2024-03-15"}""", Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("event: {event.name}") println("date: {event.date}") @@ -32,13 +32,13 @@ fn main() { -- Parse JSON with DateTime field let meeting = match json.parse("""{"title": "standup", "start": "2024-03-15T09:00:00"}""", Meeting) { Ok(m) -> m - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("meeting: {meeting.title} at {meeting.start}") -- Parse JSON with Time field let sched = match json.parse("""{"event": "lunch", "date": "2024-03-15", "time": "12:30:00"}""", Schedule) { Ok(s) -> s - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("schedule: {sched.event} on {sched.date} at {sched.time}") -- Parse a list of events @@ -50,7 +50,7 @@ fn main() { ] """, Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } events |> list.each { e -> @@ -66,6 +66,6 @@ fn main() { let bad = json.parse("""{"name": "oops", "date": "not-a-date"}""", Event) match bad { Ok(e) -> println("bad date: parsed as {e.name}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } } diff --git a/fuzz/corpus/fuzz_compiler/json_transform.silt b/fuzz/corpus/fuzz_compiler/json_transform.silt index 6d2a267a8..084edb735 100644 --- a/fuzz/corpus/fuzz_compiler/json_transform.silt +++ b/fuzz/corpus/fuzz_compiler/json_transform.silt @@ -75,7 +75,7 @@ fn main() { -- Parse the JSON dataset let employees = match json.parse_list(employee_json, Employee) { Ok(emps) -> emps - Err(e) -> panic("Failed to parse employees: {e.message()}") + Err(e) -> panic("Failed to parse employees: {Error.message(e)}") } println("=== JSON Data Pipeline ===\n") -- 1. Group by department diff --git a/fuzz/corpus/fuzz_compiler/kvstore.silt b/fuzz/corpus/fuzz_compiler/kvstore.silt index e74c39ea1..fd922cc1b 100644 --- a/fuzz/corpus/fuzz_compiler/kvstore.silt +++ b/fuzz/corpus/fuzz_compiler/kvstore.silt @@ -84,7 +84,7 @@ fn handle_save(store) { let json_str = json.stringify(store) match io.write_file(db_path, json_str) { Ok(_) -> println("OK - saved {map.length(store)} entries to {db_path}") - Err(e) -> println("Error saving: {e.message()}") + Err(e) -> println("Error saving: {Error.message(e)}") } store } @@ -92,7 +92,7 @@ fn handle_save(store) { fn handle_load() { match io.read_file(db_path) { Err(e) -> { - println("Error loading: {e.message()}") + println("Error loading: {Error.message(e)}") println("Starting with empty store.") #{} } @@ -103,7 +103,7 @@ fn handle_load() { loaded } Err(e) -> { - println("Error parsing JSON: {e.message()}") + println("Error parsing JSON: {Error.message(e)}") println("Starting with empty store.") #{} } diff --git a/fuzz/corpus/fuzz_compiler/link_checker.silt b/fuzz/corpus/fuzz_compiler/link_checker.silt index 72f749e45..6ab487d7f 100644 --- a/fuzz/corpus/fuzz_compiler/link_checker.silt +++ b/fuzz/corpus/fuzz_compiler/link_checker.silt @@ -23,7 +23,7 @@ fn main() { let content = match io.read_file(file_path) { Ok(c) -> c Err(e) -> { - println("Error reading file: {e.message()}") + println("Error reading file: {Error.message(e)}") return panic("Cannot continue without file") } } diff --git a/fuzz/corpus/fuzz_compiler/pipeline.silt b/fuzz/corpus/fuzz_compiler/pipeline.silt index dda665606..bba06791e 100644 --- a/fuzz/corpus/fuzz_compiler/pipeline.silt +++ b/fuzz/corpus/fuzz_compiler/pipeline.silt @@ -159,7 +159,7 @@ fn main() { -- Read the log file; `return` in an Err arm bails out of main. let content = match io.read_file("examples/log.txt") { Ok(c) -> c - Err(e) -> return println("Error reading log file: {e.message()}") + Err(e) -> return println("Error reading log file: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_compiler/state_machine.silt b/fuzz/corpus/fuzz_compiler/state_machine.silt index 198fb9c76..385083bc0 100644 --- a/fuzz/corpus/fuzz_compiler/state_machine.silt +++ b/fuzz/corpus/fuzz_compiler/state_machine.silt @@ -51,7 +51,7 @@ trait Display for Event { -- Print a labeled displayable value (uses where clause) fn print_labeled(label: String, value: a) where a: Display { - println("{label}: {value.display()}") + println("{label}: {value}") } -- Print a list of displayable items with a header (uses where clause) @@ -59,7 +59,7 @@ fn print_labeled(label: String, value: a) where a: Display { fn print_items(header: String, items: List(a)) where a: Display { println(header) items - |> list.each { item -> println(" - {item.display()}") } + |> list.each { item -> println(" - {item}") } } -- Look up item info from inventory; returns (quantity, price) or None @@ -155,7 +155,7 @@ fn run_machine(events, initial_state, initial_inventory) { _ -> (state2, inventory2) } let (new_state, message, new_inv) = transition(state3, event, inventory3) - let new_log = list.append(log2, (step2, event.display(), state3, new_state, message)) + let new_log = list.append(log2, (step2, "{event}", state3, new_state, message)) (new_state, new_inv, step2 + 1, new_log) } -- If we're in Dispensing state, auto-resolve it first @@ -191,7 +191,7 @@ fn main() { _ -> "{step}" } println("[{step_str}] Event: {event_str}") - println(" {old_state.display()} -> {new_state.display()}") + println(" {old_state} -> {new_state}") println(" >> {message}") println("") } diff --git a/fuzz/corpus/fuzz_compiler/time_demo.silt b/fuzz/corpus/fuzz_compiler/time_demo.silt index 0efdf76db..ea780972b 100644 --- a/fuzz/corpus/fuzz_compiler/time_demo.silt +++ b/fuzz/corpus/fuzz_compiler/time_demo.silt @@ -6,31 +6,31 @@ fn main() { let date = time.date(2024, 3, 15) match date { Ok(d) -> println("date: {d}") - Err(e) -> println("date error: {e.message()}") + Err(e) -> println("date error: {Error.message(e)}") } let bad_date = time.date(2024, 13, 1) match bad_date { Ok(d) -> println("bad date: {d}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } let t = time.time(14, 30, 0) match t { Ok(tm) -> println("time: {tm}") - Err(e) -> println("time error: {e.message()}") + Err(e) -> println("time error: {Error.message(e)}") } let bad_time = time.time(25, 0, 0) match bad_time { Ok(tm) -> println("bad time: {tm}") - Err(e) -> println("bad time: {e.message()}") + Err(e) -> println("bad time: {Error.message(e)}") } -- Compose date + time into datetime let d = match time.date(2024, 6, 15) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let tod = match time.time(9, 30, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt = time.datetime(d, tod) println("datetime: {dt}") @@ -42,11 +42,11 @@ fn main() { -- ── Formatting ────────────────────────────────────────────────────── let dt2_date = match time.date(2024, 12, 25) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let dt2_time = match time.time(18, 0, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt2 = time.datetime(dt2_date, dt2_time) println("formatted: {dt2 @@ -57,17 +57,17 @@ fn main() { let parsed = time.parse("2024-07-04 12:00:00", "%Y-%m-%d %H:%M:%S") match parsed { Ok(dt) -> println("parsed: {dt}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } let parsed_date = time.parse_date("2024-07-04", "%Y-%m-%d") match parsed_date { Ok(d) -> println("parsed date: {d}") - Err(e) -> println("parse date error: {e.message()}") + Err(e) -> println("parse date error: {Error.message(e)}") } let bad_parse = time.parse("not-a-date", "%Y-%m-%d %H:%M:%S") match bad_parse { Ok(dt) -> println("bad parse: {dt}") - Err(e) -> println("bad parse: {e.message()}") + Err(e) -> println("bad parse: {Error.message(e)}") } -- ── Date arithmetic ───────────────────────────────────────────────── let future = today @@ -79,14 +79,14 @@ fn main() { -- Month arithmetic with end-of-month clamping let jan31 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let feb_result = jan31 |> time.add_months(1) println("Jan 31 + 1 month = {feb_result}") let mar31 = match time.date(2024, 3, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let prev = mar31 |> time.add_months(-1) @@ -122,11 +122,11 @@ fn main() { println("today is: {weekday}") let d_start = match time.date(2024, 1, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d_end = match time.date(2024, 12, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let days = time.days_between(d_start, d_end) println("days in 2024: {days}") @@ -138,11 +138,11 @@ fn main() { -- ── Comparison ────────────────────────────────────────────────────── let d1 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d2 = match time.date(2024, 2, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } println("Jan 31 < Feb 1: {d1 < d2}") println("Feb 1 > Jan 31: {d2 > d1}") diff --git a/fuzz/corpus/fuzz_compiler/todo.silt b/fuzz/corpus/fuzz_compiler/todo.silt index 6b7d05a98..be223ca9c 100644 --- a/fuzz/corpus/fuzz_compiler/todo.silt +++ b/fuzz/corpus/fuzz_compiler/todo.silt @@ -61,7 +61,7 @@ fn save_todos(todos, path) { let content = json.stringify(todos) match io.write_file(path, content) { Ok(_) -> println(" Saved {list.length(todos)} todo(s) to {path}") - Err(e) -> println(" Error saving: {e.message()}") + Err(e) -> println(" Error saving: {Error.message(e)}") } } @@ -78,13 +78,13 @@ fn load_todos(path) { todos } Err(e) -> { - println(" Error parsing: {e.message()}") + println(" Error parsing: {Error.message(e)}") [] } } } Err(e) -> { - println(" Error loading: {e.message()}") + println(" Error loading: {Error.message(e)}") [] } } diff --git a/fuzz/corpus/fuzz_compiler/trait_zoo.silt b/fuzz/corpus/fuzz_compiler/trait_zoo.silt index d861f0659..9181b9b2f 100644 --- a/fuzz/corpus/fuzz_compiler/trait_zoo.silt +++ b/fuzz/corpus/fuzz_compiler/trait_zoo.silt @@ -52,7 +52,7 @@ trait Display for Color { trait Display for Styled { fn display(self) -> String { match self { - Styled(shape, color) -> "{shape.display()} in {color.display()}" + Styled(shape, color) -> "{shape} in {color}" } } } @@ -97,7 +97,7 @@ trait Perimeter for Shape { -- Generic function with where clause fn describe(item: a) where a: Display { - item.display() + "{item}" } -- Format a float to 4 decimal places diff --git a/fuzz/corpus/fuzz_compiler/traits.silt b/fuzz/corpus/fuzz_compiler/traits.silt index 794b0103a..0eaae4cc1 100644 --- a/fuzz/corpus/fuzz_compiler/traits.silt +++ b/fuzz/corpus/fuzz_compiler/traits.silt @@ -25,7 +25,7 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") shapes - |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } diff --git a/fuzz/corpus/fuzz_formatter/birthdays.silt b/fuzz/corpus/fuzz_formatter/birthdays.silt index 5cd804dd7..9431866f5 100644 --- a/fuzz/corpus/fuzz_formatter/birthdays.silt +++ b/fuzz/corpus/fuzz_formatter/birthdays.silt @@ -47,7 +47,7 @@ fn main() { ] """, Person) { Ok(p) -> p - Err(e) -> panic("Failed to parse people: {e.message()}") + Err(e) -> panic("Failed to parse people: {Error.message(e)}") } people |> list.each { p -> diff --git a/fuzz/corpus/fuzz_formatter/concurrent_processor.silt b/fuzz/corpus/fuzz_formatter/concurrent_processor.silt index a4442b900..f6b05a6f3 100644 --- a/fuzz/corpus/fuzz_formatter/concurrent_processor.silt +++ b/fuzz/corpus/fuzz_formatter/concurrent_processor.silt @@ -101,7 +101,7 @@ fn main() { } Err(err_info) -> { let (path, err) = err_info - println("[Worker {worker_id}] FAILED {path}: {err.message()}") + println("[Worker {worker_id}] FAILED {path}: {Error.message(err)}") loop(collected + 1, successes, failures + 1) } } diff --git a/fuzz/corpus/fuzz_formatter/config_parser.silt b/fuzz/corpus/fuzz_formatter/config_parser.silt index c235a060c..ead4d6960 100644 --- a/fuzz/corpus/fuzz_formatter/config_parser.silt +++ b/fuzz/corpus/fuzz_formatter/config_parser.silt @@ -143,7 +143,7 @@ fn main() { -- Read the config file let text = match io.read_file("examples/app.conf") { Ok(t) -> t - Err(e) -> return println("Error reading examples/app.conf: {e.message()}") + Err(e) -> return println("Error reading examples/app.conf: {Error.message(e)}") } println("=== Parsing config file ===") println("") diff --git a/fuzz/corpus/fuzz_formatter/csv_analyzer.silt b/fuzz/corpus/fuzz_formatter/csv_analyzer.silt index 6d2ab00d3..4bdfc6328 100644 --- a/fuzz/corpus/fuzz_formatter/csv_analyzer.silt +++ b/fuzz/corpus/fuzz_formatter/csv_analyzer.silt @@ -112,7 +112,7 @@ fn main() { -- Read and parse CSV; bail out on IO errors with a rendered message. let content = match io.read_file("examples/data.csv") { Ok(text) -> text - Err(e) -> panic("Error reading data.csv: {e.message()}") + Err(e) -> panic("Error reading data.csv: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_formatter/diff_tool.silt b/fuzz/corpus/fuzz_formatter/diff_tool.silt index 7ec90d4b8..a4716b29c 100644 --- a/fuzz/corpus/fuzz_formatter/diff_tool.silt +++ b/fuzz/corpus/fuzz_formatter/diff_tool.silt @@ -111,11 +111,11 @@ fn main() { -- Read both files, bailing out if either is missing. let old_content = match io.read_file("examples/data/original.txt") { Ok(content) -> content - Err(e) -> panic("Error reading original.txt: {e.message()}") + Err(e) -> panic("Error reading original.txt: {Error.message(e)}") } let new_content = match io.read_file("examples/data/modified.txt") { Ok(content) -> content - Err(e) -> panic("Error reading modified.txt: {e.message()}") + Err(e) -> panic("Error reading modified.txt: {Error.message(e)}") } -- Split into lines, filter out trailing empty line from final newline let old_lines = old_content diff --git a/fuzz/corpus/fuzz_formatter/expr_eval.silt b/fuzz/corpus/fuzz_formatter/expr_eval.silt index 906d51cea..f1907aaae 100644 --- a/fuzz/corpus/fuzz_formatter/expr_eval.silt +++ b/fuzz/corpus/fuzz_formatter/expr_eval.silt @@ -20,9 +20,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -205,16 +205,16 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) let rpn_str = string.join(rpn, " ") println(" RPN: {rpn_str}") let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") println(" Depth: {depth(expr)}") @@ -225,10 +225,10 @@ fn main() { -- Demonstrate deep pattern matching println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -239,7 +239,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN println("\n=== From RPN ===\n") @@ -247,7 +247,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification println("\n=== Negative Pattern Simplification ===\n") @@ -255,7 +255,7 @@ fn main() { neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") } diff --git a/fuzz/corpus/fuzz_formatter/http_client.silt b/fuzz/corpus/fuzz_formatter/http_client.silt index 5ebaa97db..12a3ca26f 100644 --- a/fuzz/corpus/fuzz_formatter/http_client.silt +++ b/fuzz/corpus/fuzz_formatter/http_client.silt @@ -20,16 +20,16 @@ fn fetch_repos(user) { -- its caller. let resp = match http.get("https://api.github.com/users/{user}/repos") { Ok(r) -> r - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } -- The body is the bytes that arrived; JSON is text. let text = match bytes.to_string(resp.body) { Ok(text) -> text - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } match json.parse_list(text, Repo) { Ok(repos) -> Ok(repos) - Err(e) -> Err(e.message()) + Err(e) -> Err(Error.message(e)) } } diff --git a/fuzz/corpus/fuzz_formatter/http_server.silt b/fuzz/corpus/fuzz_formatter/http_server.silt index cff3c0e01..e9c253201 100644 --- a/fuzz/corpus/fuzz_formatter/http_server.silt +++ b/fuzz/corpus/fuzz_formatter/http_server.silt @@ -47,9 +47,9 @@ fn main() { (http.POST, ["todos"]) -> match bytes.to_string(req.body) { Ok(text) -> match json.parse(text, Todo) { Ok(todo) -> json_response(201, todo) - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } (http.GET, ["todos", id_str]) -> match int.parse(id_str) { Ok(id) -> json_response(200, Todo { id: id, title: "Todo {id}", done: false }) diff --git a/fuzz/corpus/fuzz_formatter/json_time.silt b/fuzz/corpus/fuzz_formatter/json_time.silt index 86ccc60c4..5c599757c 100644 --- a/fuzz/corpus/fuzz_formatter/json_time.silt +++ b/fuzz/corpus/fuzz_formatter/json_time.silt @@ -22,7 +22,7 @@ fn main() { -- Parse JSON with Date field let event = match json.parse("""{"name": "launch", "date": "2024-03-15"}""", Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("event: {event.name}") println("date: {event.date}") @@ -32,13 +32,13 @@ fn main() { -- Parse JSON with DateTime field let meeting = match json.parse("""{"title": "standup", "start": "2024-03-15T09:00:00"}""", Meeting) { Ok(m) -> m - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("meeting: {meeting.title} at {meeting.start}") -- Parse JSON with Time field let sched = match json.parse("""{"event": "lunch", "date": "2024-03-15", "time": "12:30:00"}""", Schedule) { Ok(s) -> s - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("schedule: {sched.event} on {sched.date} at {sched.time}") -- Parse a list of events @@ -50,7 +50,7 @@ fn main() { ] """, Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } events |> list.each { e -> @@ -66,6 +66,6 @@ fn main() { let bad = json.parse("""{"name": "oops", "date": "not-a-date"}""", Event) match bad { Ok(e) -> println("bad date: parsed as {e.name}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } } diff --git a/fuzz/corpus/fuzz_formatter/json_transform.silt b/fuzz/corpus/fuzz_formatter/json_transform.silt index 6d2a267a8..084edb735 100644 --- a/fuzz/corpus/fuzz_formatter/json_transform.silt +++ b/fuzz/corpus/fuzz_formatter/json_transform.silt @@ -75,7 +75,7 @@ fn main() { -- Parse the JSON dataset let employees = match json.parse_list(employee_json, Employee) { Ok(emps) -> emps - Err(e) -> panic("Failed to parse employees: {e.message()}") + Err(e) -> panic("Failed to parse employees: {Error.message(e)}") } println("=== JSON Data Pipeline ===\n") -- 1. Group by department diff --git a/fuzz/corpus/fuzz_formatter/kvstore.silt b/fuzz/corpus/fuzz_formatter/kvstore.silt index e74c39ea1..fd922cc1b 100644 --- a/fuzz/corpus/fuzz_formatter/kvstore.silt +++ b/fuzz/corpus/fuzz_formatter/kvstore.silt @@ -84,7 +84,7 @@ fn handle_save(store) { let json_str = json.stringify(store) match io.write_file(db_path, json_str) { Ok(_) -> println("OK - saved {map.length(store)} entries to {db_path}") - Err(e) -> println("Error saving: {e.message()}") + Err(e) -> println("Error saving: {Error.message(e)}") } store } @@ -92,7 +92,7 @@ fn handle_save(store) { fn handle_load() { match io.read_file(db_path) { Err(e) -> { - println("Error loading: {e.message()}") + println("Error loading: {Error.message(e)}") println("Starting with empty store.") #{} } @@ -103,7 +103,7 @@ fn handle_load() { loaded } Err(e) -> { - println("Error parsing JSON: {e.message()}") + println("Error parsing JSON: {Error.message(e)}") println("Starting with empty store.") #{} } diff --git a/fuzz/corpus/fuzz_formatter/link_checker.silt b/fuzz/corpus/fuzz_formatter/link_checker.silt index 72f749e45..6ab487d7f 100644 --- a/fuzz/corpus/fuzz_formatter/link_checker.silt +++ b/fuzz/corpus/fuzz_formatter/link_checker.silt @@ -23,7 +23,7 @@ fn main() { let content = match io.read_file(file_path) { Ok(c) -> c Err(e) -> { - println("Error reading file: {e.message()}") + println("Error reading file: {Error.message(e)}") return panic("Cannot continue without file") } } diff --git a/fuzz/corpus/fuzz_formatter/pipeline.silt b/fuzz/corpus/fuzz_formatter/pipeline.silt index dda665606..bba06791e 100644 --- a/fuzz/corpus/fuzz_formatter/pipeline.silt +++ b/fuzz/corpus/fuzz_formatter/pipeline.silt @@ -159,7 +159,7 @@ fn main() { -- Read the log file; `return` in an Err arm bails out of main. let content = match io.read_file("examples/log.txt") { Ok(c) -> c - Err(e) -> return println("Error reading log file: {e.message()}") + Err(e) -> return println("Error reading log file: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_formatter/state_machine.silt b/fuzz/corpus/fuzz_formatter/state_machine.silt index 198fb9c76..385083bc0 100644 --- a/fuzz/corpus/fuzz_formatter/state_machine.silt +++ b/fuzz/corpus/fuzz_formatter/state_machine.silt @@ -51,7 +51,7 @@ trait Display for Event { -- Print a labeled displayable value (uses where clause) fn print_labeled(label: String, value: a) where a: Display { - println("{label}: {value.display()}") + println("{label}: {value}") } -- Print a list of displayable items with a header (uses where clause) @@ -59,7 +59,7 @@ fn print_labeled(label: String, value: a) where a: Display { fn print_items(header: String, items: List(a)) where a: Display { println(header) items - |> list.each { item -> println(" - {item.display()}") } + |> list.each { item -> println(" - {item}") } } -- Look up item info from inventory; returns (quantity, price) or None @@ -155,7 +155,7 @@ fn run_machine(events, initial_state, initial_inventory) { _ -> (state2, inventory2) } let (new_state, message, new_inv) = transition(state3, event, inventory3) - let new_log = list.append(log2, (step2, event.display(), state3, new_state, message)) + let new_log = list.append(log2, (step2, "{event}", state3, new_state, message)) (new_state, new_inv, step2 + 1, new_log) } -- If we're in Dispensing state, auto-resolve it first @@ -191,7 +191,7 @@ fn main() { _ -> "{step}" } println("[{step_str}] Event: {event_str}") - println(" {old_state.display()} -> {new_state.display()}") + println(" {old_state} -> {new_state}") println(" >> {message}") println("") } diff --git a/fuzz/corpus/fuzz_formatter/time_demo.silt b/fuzz/corpus/fuzz_formatter/time_demo.silt index 0efdf76db..ea780972b 100644 --- a/fuzz/corpus/fuzz_formatter/time_demo.silt +++ b/fuzz/corpus/fuzz_formatter/time_demo.silt @@ -6,31 +6,31 @@ fn main() { let date = time.date(2024, 3, 15) match date { Ok(d) -> println("date: {d}") - Err(e) -> println("date error: {e.message()}") + Err(e) -> println("date error: {Error.message(e)}") } let bad_date = time.date(2024, 13, 1) match bad_date { Ok(d) -> println("bad date: {d}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } let t = time.time(14, 30, 0) match t { Ok(tm) -> println("time: {tm}") - Err(e) -> println("time error: {e.message()}") + Err(e) -> println("time error: {Error.message(e)}") } let bad_time = time.time(25, 0, 0) match bad_time { Ok(tm) -> println("bad time: {tm}") - Err(e) -> println("bad time: {e.message()}") + Err(e) -> println("bad time: {Error.message(e)}") } -- Compose date + time into datetime let d = match time.date(2024, 6, 15) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let tod = match time.time(9, 30, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt = time.datetime(d, tod) println("datetime: {dt}") @@ -42,11 +42,11 @@ fn main() { -- ── Formatting ────────────────────────────────────────────────────── let dt2_date = match time.date(2024, 12, 25) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let dt2_time = match time.time(18, 0, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt2 = time.datetime(dt2_date, dt2_time) println("formatted: {dt2 @@ -57,17 +57,17 @@ fn main() { let parsed = time.parse("2024-07-04 12:00:00", "%Y-%m-%d %H:%M:%S") match parsed { Ok(dt) -> println("parsed: {dt}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } let parsed_date = time.parse_date("2024-07-04", "%Y-%m-%d") match parsed_date { Ok(d) -> println("parsed date: {d}") - Err(e) -> println("parse date error: {e.message()}") + Err(e) -> println("parse date error: {Error.message(e)}") } let bad_parse = time.parse("not-a-date", "%Y-%m-%d %H:%M:%S") match bad_parse { Ok(dt) -> println("bad parse: {dt}") - Err(e) -> println("bad parse: {e.message()}") + Err(e) -> println("bad parse: {Error.message(e)}") } -- ── Date arithmetic ───────────────────────────────────────────────── let future = today @@ -79,14 +79,14 @@ fn main() { -- Month arithmetic with end-of-month clamping let jan31 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let feb_result = jan31 |> time.add_months(1) println("Jan 31 + 1 month = {feb_result}") let mar31 = match time.date(2024, 3, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let prev = mar31 |> time.add_months(-1) @@ -122,11 +122,11 @@ fn main() { println("today is: {weekday}") let d_start = match time.date(2024, 1, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d_end = match time.date(2024, 12, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let days = time.days_between(d_start, d_end) println("days in 2024: {days}") @@ -138,11 +138,11 @@ fn main() { -- ── Comparison ────────────────────────────────────────────────────── let d1 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d2 = match time.date(2024, 2, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } println("Jan 31 < Feb 1: {d1 < d2}") println("Feb 1 > Jan 31: {d2 > d1}") diff --git a/fuzz/corpus/fuzz_formatter/todo.silt b/fuzz/corpus/fuzz_formatter/todo.silt index 6b7d05a98..be223ca9c 100644 --- a/fuzz/corpus/fuzz_formatter/todo.silt +++ b/fuzz/corpus/fuzz_formatter/todo.silt @@ -61,7 +61,7 @@ fn save_todos(todos, path) { let content = json.stringify(todos) match io.write_file(path, content) { Ok(_) -> println(" Saved {list.length(todos)} todo(s) to {path}") - Err(e) -> println(" Error saving: {e.message()}") + Err(e) -> println(" Error saving: {Error.message(e)}") } } @@ -78,13 +78,13 @@ fn load_todos(path) { todos } Err(e) -> { - println(" Error parsing: {e.message()}") + println(" Error parsing: {Error.message(e)}") [] } } } Err(e) -> { - println(" Error loading: {e.message()}") + println(" Error loading: {Error.message(e)}") [] } } diff --git a/fuzz/corpus/fuzz_formatter/trait_zoo.silt b/fuzz/corpus/fuzz_formatter/trait_zoo.silt index d861f0659..9181b9b2f 100644 --- a/fuzz/corpus/fuzz_formatter/trait_zoo.silt +++ b/fuzz/corpus/fuzz_formatter/trait_zoo.silt @@ -52,7 +52,7 @@ trait Display for Color { trait Display for Styled { fn display(self) -> String { match self { - Styled(shape, color) -> "{shape.display()} in {color.display()}" + Styled(shape, color) -> "{shape} in {color}" } } } @@ -97,7 +97,7 @@ trait Perimeter for Shape { -- Generic function with where clause fn describe(item: a) where a: Display { - item.display() + "{item}" } -- Format a float to 4 decimal places diff --git a/fuzz/corpus/fuzz_formatter/traits.silt b/fuzz/corpus/fuzz_formatter/traits.silt index 794b0103a..0eaae4cc1 100644 --- a/fuzz/corpus/fuzz_formatter/traits.silt +++ b/fuzz/corpus/fuzz_formatter/traits.silt @@ -25,7 +25,7 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") shapes - |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } diff --git a/fuzz/corpus/fuzz_lexer/birthdays.silt b/fuzz/corpus/fuzz_lexer/birthdays.silt index 5cd804dd7..9431866f5 100644 --- a/fuzz/corpus/fuzz_lexer/birthdays.silt +++ b/fuzz/corpus/fuzz_lexer/birthdays.silt @@ -47,7 +47,7 @@ fn main() { ] """, Person) { Ok(p) -> p - Err(e) -> panic("Failed to parse people: {e.message()}") + Err(e) -> panic("Failed to parse people: {Error.message(e)}") } people |> list.each { p -> diff --git a/fuzz/corpus/fuzz_lexer/concurrent_processor.silt b/fuzz/corpus/fuzz_lexer/concurrent_processor.silt index a4442b900..f6b05a6f3 100644 --- a/fuzz/corpus/fuzz_lexer/concurrent_processor.silt +++ b/fuzz/corpus/fuzz_lexer/concurrent_processor.silt @@ -101,7 +101,7 @@ fn main() { } Err(err_info) -> { let (path, err) = err_info - println("[Worker {worker_id}] FAILED {path}: {err.message()}") + println("[Worker {worker_id}] FAILED {path}: {Error.message(err)}") loop(collected + 1, successes, failures + 1) } } diff --git a/fuzz/corpus/fuzz_lexer/config_parser.silt b/fuzz/corpus/fuzz_lexer/config_parser.silt index c235a060c..ead4d6960 100644 --- a/fuzz/corpus/fuzz_lexer/config_parser.silt +++ b/fuzz/corpus/fuzz_lexer/config_parser.silt @@ -143,7 +143,7 @@ fn main() { -- Read the config file let text = match io.read_file("examples/app.conf") { Ok(t) -> t - Err(e) -> return println("Error reading examples/app.conf: {e.message()}") + Err(e) -> return println("Error reading examples/app.conf: {Error.message(e)}") } println("=== Parsing config file ===") println("") diff --git a/fuzz/corpus/fuzz_lexer/csv_analyzer.silt b/fuzz/corpus/fuzz_lexer/csv_analyzer.silt index 6d2ab00d3..4bdfc6328 100644 --- a/fuzz/corpus/fuzz_lexer/csv_analyzer.silt +++ b/fuzz/corpus/fuzz_lexer/csv_analyzer.silt @@ -112,7 +112,7 @@ fn main() { -- Read and parse CSV; bail out on IO errors with a rendered message. let content = match io.read_file("examples/data.csv") { Ok(text) -> text - Err(e) -> panic("Error reading data.csv: {e.message()}") + Err(e) -> panic("Error reading data.csv: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_lexer/diff_tool.silt b/fuzz/corpus/fuzz_lexer/diff_tool.silt index 7ec90d4b8..a4716b29c 100644 --- a/fuzz/corpus/fuzz_lexer/diff_tool.silt +++ b/fuzz/corpus/fuzz_lexer/diff_tool.silt @@ -111,11 +111,11 @@ fn main() { -- Read both files, bailing out if either is missing. let old_content = match io.read_file("examples/data/original.txt") { Ok(content) -> content - Err(e) -> panic("Error reading original.txt: {e.message()}") + Err(e) -> panic("Error reading original.txt: {Error.message(e)}") } let new_content = match io.read_file("examples/data/modified.txt") { Ok(content) -> content - Err(e) -> panic("Error reading modified.txt: {e.message()}") + Err(e) -> panic("Error reading modified.txt: {Error.message(e)}") } -- Split into lines, filter out trailing empty line from final newline let old_lines = old_content diff --git a/fuzz/corpus/fuzz_lexer/expr_eval.silt b/fuzz/corpus/fuzz_lexer/expr_eval.silt index 906d51cea..f1907aaae 100644 --- a/fuzz/corpus/fuzz_lexer/expr_eval.silt +++ b/fuzz/corpus/fuzz_lexer/expr_eval.silt @@ -20,9 +20,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -205,16 +205,16 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) let rpn_str = string.join(rpn, " ") println(" RPN: {rpn_str}") let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") println(" Depth: {depth(expr)}") @@ -225,10 +225,10 @@ fn main() { -- Demonstrate deep pattern matching println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -239,7 +239,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN println("\n=== From RPN ===\n") @@ -247,7 +247,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification println("\n=== Negative Pattern Simplification ===\n") @@ -255,7 +255,7 @@ fn main() { neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") } diff --git a/fuzz/corpus/fuzz_lexer/http_client.silt b/fuzz/corpus/fuzz_lexer/http_client.silt index 5ebaa97db..12a3ca26f 100644 --- a/fuzz/corpus/fuzz_lexer/http_client.silt +++ b/fuzz/corpus/fuzz_lexer/http_client.silt @@ -20,16 +20,16 @@ fn fetch_repos(user) { -- its caller. let resp = match http.get("https://api.github.com/users/{user}/repos") { Ok(r) -> r - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } -- The body is the bytes that arrived; JSON is text. let text = match bytes.to_string(resp.body) { Ok(text) -> text - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } match json.parse_list(text, Repo) { Ok(repos) -> Ok(repos) - Err(e) -> Err(e.message()) + Err(e) -> Err(Error.message(e)) } } diff --git a/fuzz/corpus/fuzz_lexer/http_server.silt b/fuzz/corpus/fuzz_lexer/http_server.silt index cff3c0e01..e9c253201 100644 --- a/fuzz/corpus/fuzz_lexer/http_server.silt +++ b/fuzz/corpus/fuzz_lexer/http_server.silt @@ -47,9 +47,9 @@ fn main() { (http.POST, ["todos"]) -> match bytes.to_string(req.body) { Ok(text) -> match json.parse(text, Todo) { Ok(todo) -> json_response(201, todo) - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } (http.GET, ["todos", id_str]) -> match int.parse(id_str) { Ok(id) -> json_response(200, Todo { id: id, title: "Todo {id}", done: false }) diff --git a/fuzz/corpus/fuzz_lexer/json_time.silt b/fuzz/corpus/fuzz_lexer/json_time.silt index 86ccc60c4..5c599757c 100644 --- a/fuzz/corpus/fuzz_lexer/json_time.silt +++ b/fuzz/corpus/fuzz_lexer/json_time.silt @@ -22,7 +22,7 @@ fn main() { -- Parse JSON with Date field let event = match json.parse("""{"name": "launch", "date": "2024-03-15"}""", Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("event: {event.name}") println("date: {event.date}") @@ -32,13 +32,13 @@ fn main() { -- Parse JSON with DateTime field let meeting = match json.parse("""{"title": "standup", "start": "2024-03-15T09:00:00"}""", Meeting) { Ok(m) -> m - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("meeting: {meeting.title} at {meeting.start}") -- Parse JSON with Time field let sched = match json.parse("""{"event": "lunch", "date": "2024-03-15", "time": "12:30:00"}""", Schedule) { Ok(s) -> s - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("schedule: {sched.event} on {sched.date} at {sched.time}") -- Parse a list of events @@ -50,7 +50,7 @@ fn main() { ] """, Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } events |> list.each { e -> @@ -66,6 +66,6 @@ fn main() { let bad = json.parse("""{"name": "oops", "date": "not-a-date"}""", Event) match bad { Ok(e) -> println("bad date: parsed as {e.name}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } } diff --git a/fuzz/corpus/fuzz_lexer/json_transform.silt b/fuzz/corpus/fuzz_lexer/json_transform.silt index 6d2a267a8..084edb735 100644 --- a/fuzz/corpus/fuzz_lexer/json_transform.silt +++ b/fuzz/corpus/fuzz_lexer/json_transform.silt @@ -75,7 +75,7 @@ fn main() { -- Parse the JSON dataset let employees = match json.parse_list(employee_json, Employee) { Ok(emps) -> emps - Err(e) -> panic("Failed to parse employees: {e.message()}") + Err(e) -> panic("Failed to parse employees: {Error.message(e)}") } println("=== JSON Data Pipeline ===\n") -- 1. Group by department diff --git a/fuzz/corpus/fuzz_lexer/kvstore.silt b/fuzz/corpus/fuzz_lexer/kvstore.silt index e74c39ea1..fd922cc1b 100644 --- a/fuzz/corpus/fuzz_lexer/kvstore.silt +++ b/fuzz/corpus/fuzz_lexer/kvstore.silt @@ -84,7 +84,7 @@ fn handle_save(store) { let json_str = json.stringify(store) match io.write_file(db_path, json_str) { Ok(_) -> println("OK - saved {map.length(store)} entries to {db_path}") - Err(e) -> println("Error saving: {e.message()}") + Err(e) -> println("Error saving: {Error.message(e)}") } store } @@ -92,7 +92,7 @@ fn handle_save(store) { fn handle_load() { match io.read_file(db_path) { Err(e) -> { - println("Error loading: {e.message()}") + println("Error loading: {Error.message(e)}") println("Starting with empty store.") #{} } @@ -103,7 +103,7 @@ fn handle_load() { loaded } Err(e) -> { - println("Error parsing JSON: {e.message()}") + println("Error parsing JSON: {Error.message(e)}") println("Starting with empty store.") #{} } diff --git a/fuzz/corpus/fuzz_lexer/link_checker.silt b/fuzz/corpus/fuzz_lexer/link_checker.silt index 72f749e45..6ab487d7f 100644 --- a/fuzz/corpus/fuzz_lexer/link_checker.silt +++ b/fuzz/corpus/fuzz_lexer/link_checker.silt @@ -23,7 +23,7 @@ fn main() { let content = match io.read_file(file_path) { Ok(c) -> c Err(e) -> { - println("Error reading file: {e.message()}") + println("Error reading file: {Error.message(e)}") return panic("Cannot continue without file") } } diff --git a/fuzz/corpus/fuzz_lexer/pipeline.silt b/fuzz/corpus/fuzz_lexer/pipeline.silt index dda665606..bba06791e 100644 --- a/fuzz/corpus/fuzz_lexer/pipeline.silt +++ b/fuzz/corpus/fuzz_lexer/pipeline.silt @@ -159,7 +159,7 @@ fn main() { -- Read the log file; `return` in an Err arm bails out of main. let content = match io.read_file("examples/log.txt") { Ok(c) -> c - Err(e) -> return println("Error reading log file: {e.message()}") + Err(e) -> return println("Error reading log file: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_lexer/state_machine.silt b/fuzz/corpus/fuzz_lexer/state_machine.silt index 198fb9c76..385083bc0 100644 --- a/fuzz/corpus/fuzz_lexer/state_machine.silt +++ b/fuzz/corpus/fuzz_lexer/state_machine.silt @@ -51,7 +51,7 @@ trait Display for Event { -- Print a labeled displayable value (uses where clause) fn print_labeled(label: String, value: a) where a: Display { - println("{label}: {value.display()}") + println("{label}: {value}") } -- Print a list of displayable items with a header (uses where clause) @@ -59,7 +59,7 @@ fn print_labeled(label: String, value: a) where a: Display { fn print_items(header: String, items: List(a)) where a: Display { println(header) items - |> list.each { item -> println(" - {item.display()}") } + |> list.each { item -> println(" - {item}") } } -- Look up item info from inventory; returns (quantity, price) or None @@ -155,7 +155,7 @@ fn run_machine(events, initial_state, initial_inventory) { _ -> (state2, inventory2) } let (new_state, message, new_inv) = transition(state3, event, inventory3) - let new_log = list.append(log2, (step2, event.display(), state3, new_state, message)) + let new_log = list.append(log2, (step2, "{event}", state3, new_state, message)) (new_state, new_inv, step2 + 1, new_log) } -- If we're in Dispensing state, auto-resolve it first @@ -191,7 +191,7 @@ fn main() { _ -> "{step}" } println("[{step_str}] Event: {event_str}") - println(" {old_state.display()} -> {new_state.display()}") + println(" {old_state} -> {new_state}") println(" >> {message}") println("") } diff --git a/fuzz/corpus/fuzz_lexer/time_demo.silt b/fuzz/corpus/fuzz_lexer/time_demo.silt index 0efdf76db..ea780972b 100644 --- a/fuzz/corpus/fuzz_lexer/time_demo.silt +++ b/fuzz/corpus/fuzz_lexer/time_demo.silt @@ -6,31 +6,31 @@ fn main() { let date = time.date(2024, 3, 15) match date { Ok(d) -> println("date: {d}") - Err(e) -> println("date error: {e.message()}") + Err(e) -> println("date error: {Error.message(e)}") } let bad_date = time.date(2024, 13, 1) match bad_date { Ok(d) -> println("bad date: {d}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } let t = time.time(14, 30, 0) match t { Ok(tm) -> println("time: {tm}") - Err(e) -> println("time error: {e.message()}") + Err(e) -> println("time error: {Error.message(e)}") } let bad_time = time.time(25, 0, 0) match bad_time { Ok(tm) -> println("bad time: {tm}") - Err(e) -> println("bad time: {e.message()}") + Err(e) -> println("bad time: {Error.message(e)}") } -- Compose date + time into datetime let d = match time.date(2024, 6, 15) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let tod = match time.time(9, 30, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt = time.datetime(d, tod) println("datetime: {dt}") @@ -42,11 +42,11 @@ fn main() { -- ── Formatting ────────────────────────────────────────────────────── let dt2_date = match time.date(2024, 12, 25) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let dt2_time = match time.time(18, 0, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt2 = time.datetime(dt2_date, dt2_time) println("formatted: {dt2 @@ -57,17 +57,17 @@ fn main() { let parsed = time.parse("2024-07-04 12:00:00", "%Y-%m-%d %H:%M:%S") match parsed { Ok(dt) -> println("parsed: {dt}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } let parsed_date = time.parse_date("2024-07-04", "%Y-%m-%d") match parsed_date { Ok(d) -> println("parsed date: {d}") - Err(e) -> println("parse date error: {e.message()}") + Err(e) -> println("parse date error: {Error.message(e)}") } let bad_parse = time.parse("not-a-date", "%Y-%m-%d %H:%M:%S") match bad_parse { Ok(dt) -> println("bad parse: {dt}") - Err(e) -> println("bad parse: {e.message()}") + Err(e) -> println("bad parse: {Error.message(e)}") } -- ── Date arithmetic ───────────────────────────────────────────────── let future = today @@ -79,14 +79,14 @@ fn main() { -- Month arithmetic with end-of-month clamping let jan31 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let feb_result = jan31 |> time.add_months(1) println("Jan 31 + 1 month = {feb_result}") let mar31 = match time.date(2024, 3, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let prev = mar31 |> time.add_months(-1) @@ -122,11 +122,11 @@ fn main() { println("today is: {weekday}") let d_start = match time.date(2024, 1, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d_end = match time.date(2024, 12, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let days = time.days_between(d_start, d_end) println("days in 2024: {days}") @@ -138,11 +138,11 @@ fn main() { -- ── Comparison ────────────────────────────────────────────────────── let d1 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d2 = match time.date(2024, 2, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } println("Jan 31 < Feb 1: {d1 < d2}") println("Feb 1 > Jan 31: {d2 > d1}") diff --git a/fuzz/corpus/fuzz_lexer/todo.silt b/fuzz/corpus/fuzz_lexer/todo.silt index 6b7d05a98..be223ca9c 100644 --- a/fuzz/corpus/fuzz_lexer/todo.silt +++ b/fuzz/corpus/fuzz_lexer/todo.silt @@ -61,7 +61,7 @@ fn save_todos(todos, path) { let content = json.stringify(todos) match io.write_file(path, content) { Ok(_) -> println(" Saved {list.length(todos)} todo(s) to {path}") - Err(e) -> println(" Error saving: {e.message()}") + Err(e) -> println(" Error saving: {Error.message(e)}") } } @@ -78,13 +78,13 @@ fn load_todos(path) { todos } Err(e) -> { - println(" Error parsing: {e.message()}") + println(" Error parsing: {Error.message(e)}") [] } } } Err(e) -> { - println(" Error loading: {e.message()}") + println(" Error loading: {Error.message(e)}") [] } } diff --git a/fuzz/corpus/fuzz_lexer/trait_zoo.silt b/fuzz/corpus/fuzz_lexer/trait_zoo.silt index d861f0659..9181b9b2f 100644 --- a/fuzz/corpus/fuzz_lexer/trait_zoo.silt +++ b/fuzz/corpus/fuzz_lexer/trait_zoo.silt @@ -52,7 +52,7 @@ trait Display for Color { trait Display for Styled { fn display(self) -> String { match self { - Styled(shape, color) -> "{shape.display()} in {color.display()}" + Styled(shape, color) -> "{shape} in {color}" } } } @@ -97,7 +97,7 @@ trait Perimeter for Shape { -- Generic function with where clause fn describe(item: a) where a: Display { - item.display() + "{item}" } -- Format a float to 4 decimal places diff --git a/fuzz/corpus/fuzz_lexer/traits.silt b/fuzz/corpus/fuzz_lexer/traits.silt index 794b0103a..0eaae4cc1 100644 --- a/fuzz/corpus/fuzz_lexer/traits.silt +++ b/fuzz/corpus/fuzz_lexer/traits.silt @@ -25,7 +25,7 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") shapes - |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } diff --git a/fuzz/corpus/fuzz_parser/birthdays.silt b/fuzz/corpus/fuzz_parser/birthdays.silt index 5cd804dd7..9431866f5 100644 --- a/fuzz/corpus/fuzz_parser/birthdays.silt +++ b/fuzz/corpus/fuzz_parser/birthdays.silt @@ -47,7 +47,7 @@ fn main() { ] """, Person) { Ok(p) -> p - Err(e) -> panic("Failed to parse people: {e.message()}") + Err(e) -> panic("Failed to parse people: {Error.message(e)}") } people |> list.each { p -> diff --git a/fuzz/corpus/fuzz_parser/concurrent_processor.silt b/fuzz/corpus/fuzz_parser/concurrent_processor.silt index a4442b900..f6b05a6f3 100644 --- a/fuzz/corpus/fuzz_parser/concurrent_processor.silt +++ b/fuzz/corpus/fuzz_parser/concurrent_processor.silt @@ -101,7 +101,7 @@ fn main() { } Err(err_info) -> { let (path, err) = err_info - println("[Worker {worker_id}] FAILED {path}: {err.message()}") + println("[Worker {worker_id}] FAILED {path}: {Error.message(err)}") loop(collected + 1, successes, failures + 1) } } diff --git a/fuzz/corpus/fuzz_parser/config_parser.silt b/fuzz/corpus/fuzz_parser/config_parser.silt index c235a060c..ead4d6960 100644 --- a/fuzz/corpus/fuzz_parser/config_parser.silt +++ b/fuzz/corpus/fuzz_parser/config_parser.silt @@ -143,7 +143,7 @@ fn main() { -- Read the config file let text = match io.read_file("examples/app.conf") { Ok(t) -> t - Err(e) -> return println("Error reading examples/app.conf: {e.message()}") + Err(e) -> return println("Error reading examples/app.conf: {Error.message(e)}") } println("=== Parsing config file ===") println("") diff --git a/fuzz/corpus/fuzz_parser/csv_analyzer.silt b/fuzz/corpus/fuzz_parser/csv_analyzer.silt index 6d2ab00d3..4bdfc6328 100644 --- a/fuzz/corpus/fuzz_parser/csv_analyzer.silt +++ b/fuzz/corpus/fuzz_parser/csv_analyzer.silt @@ -112,7 +112,7 @@ fn main() { -- Read and parse CSV; bail out on IO errors with a rendered message. let content = match io.read_file("examples/data.csv") { Ok(text) -> text - Err(e) -> panic("Error reading data.csv: {e.message()}") + Err(e) -> panic("Error reading data.csv: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_parser/diff_tool.silt b/fuzz/corpus/fuzz_parser/diff_tool.silt index 7ec90d4b8..a4716b29c 100644 --- a/fuzz/corpus/fuzz_parser/diff_tool.silt +++ b/fuzz/corpus/fuzz_parser/diff_tool.silt @@ -111,11 +111,11 @@ fn main() { -- Read both files, bailing out if either is missing. let old_content = match io.read_file("examples/data/original.txt") { Ok(content) -> content - Err(e) -> panic("Error reading original.txt: {e.message()}") + Err(e) -> panic("Error reading original.txt: {Error.message(e)}") } let new_content = match io.read_file("examples/data/modified.txt") { Ok(content) -> content - Err(e) -> panic("Error reading modified.txt: {e.message()}") + Err(e) -> panic("Error reading modified.txt: {Error.message(e)}") } -- Split into lines, filter out trailing empty line from final newline let old_lines = old_content diff --git a/fuzz/corpus/fuzz_parser/expr_eval.silt b/fuzz/corpus/fuzz_parser/expr_eval.silt index 906d51cea..f1907aaae 100644 --- a/fuzz/corpus/fuzz_parser/expr_eval.silt +++ b/fuzz/corpus/fuzz_parser/expr_eval.silt @@ -20,9 +20,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -205,16 +205,16 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) let rpn_str = string.join(rpn, " ") println(" RPN: {rpn_str}") let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") println(" Depth: {depth(expr)}") @@ -225,10 +225,10 @@ fn main() { -- Demonstrate deep pattern matching println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -239,7 +239,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN println("\n=== From RPN ===\n") @@ -247,7 +247,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification println("\n=== Negative Pattern Simplification ===\n") @@ -255,7 +255,7 @@ fn main() { neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") } diff --git a/fuzz/corpus/fuzz_parser/http_client.silt b/fuzz/corpus/fuzz_parser/http_client.silt index 5ebaa97db..12a3ca26f 100644 --- a/fuzz/corpus/fuzz_parser/http_client.silt +++ b/fuzz/corpus/fuzz_parser/http_client.silt @@ -20,16 +20,16 @@ fn fetch_repos(user) { -- its caller. let resp = match http.get("https://api.github.com/users/{user}/repos") { Ok(r) -> r - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } -- The body is the bytes that arrived; JSON is text. let text = match bytes.to_string(resp.body) { Ok(text) -> text - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } match json.parse_list(text, Repo) { Ok(repos) -> Ok(repos) - Err(e) -> Err(e.message()) + Err(e) -> Err(Error.message(e)) } } diff --git a/fuzz/corpus/fuzz_parser/http_server.silt b/fuzz/corpus/fuzz_parser/http_server.silt index cff3c0e01..e9c253201 100644 --- a/fuzz/corpus/fuzz_parser/http_server.silt +++ b/fuzz/corpus/fuzz_parser/http_server.silt @@ -47,9 +47,9 @@ fn main() { (http.POST, ["todos"]) -> match bytes.to_string(req.body) { Ok(text) -> match json.parse(text, Todo) { Ok(todo) -> json_response(201, todo) - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } (http.GET, ["todos", id_str]) -> match int.parse(id_str) { Ok(id) -> json_response(200, Todo { id: id, title: "Todo {id}", done: false }) diff --git a/fuzz/corpus/fuzz_parser/json_time.silt b/fuzz/corpus/fuzz_parser/json_time.silt index 86ccc60c4..5c599757c 100644 --- a/fuzz/corpus/fuzz_parser/json_time.silt +++ b/fuzz/corpus/fuzz_parser/json_time.silt @@ -22,7 +22,7 @@ fn main() { -- Parse JSON with Date field let event = match json.parse("""{"name": "launch", "date": "2024-03-15"}""", Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("event: {event.name}") println("date: {event.date}") @@ -32,13 +32,13 @@ fn main() { -- Parse JSON with DateTime field let meeting = match json.parse("""{"title": "standup", "start": "2024-03-15T09:00:00"}""", Meeting) { Ok(m) -> m - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("meeting: {meeting.title} at {meeting.start}") -- Parse JSON with Time field let sched = match json.parse("""{"event": "lunch", "date": "2024-03-15", "time": "12:30:00"}""", Schedule) { Ok(s) -> s - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("schedule: {sched.event} on {sched.date} at {sched.time}") -- Parse a list of events @@ -50,7 +50,7 @@ fn main() { ] """, Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } events |> list.each { e -> @@ -66,6 +66,6 @@ fn main() { let bad = json.parse("""{"name": "oops", "date": "not-a-date"}""", Event) match bad { Ok(e) -> println("bad date: parsed as {e.name}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } } diff --git a/fuzz/corpus/fuzz_parser/json_transform.silt b/fuzz/corpus/fuzz_parser/json_transform.silt index 6d2a267a8..084edb735 100644 --- a/fuzz/corpus/fuzz_parser/json_transform.silt +++ b/fuzz/corpus/fuzz_parser/json_transform.silt @@ -75,7 +75,7 @@ fn main() { -- Parse the JSON dataset let employees = match json.parse_list(employee_json, Employee) { Ok(emps) -> emps - Err(e) -> panic("Failed to parse employees: {e.message()}") + Err(e) -> panic("Failed to parse employees: {Error.message(e)}") } println("=== JSON Data Pipeline ===\n") -- 1. Group by department diff --git a/fuzz/corpus/fuzz_parser/kvstore.silt b/fuzz/corpus/fuzz_parser/kvstore.silt index e74c39ea1..fd922cc1b 100644 --- a/fuzz/corpus/fuzz_parser/kvstore.silt +++ b/fuzz/corpus/fuzz_parser/kvstore.silt @@ -84,7 +84,7 @@ fn handle_save(store) { let json_str = json.stringify(store) match io.write_file(db_path, json_str) { Ok(_) -> println("OK - saved {map.length(store)} entries to {db_path}") - Err(e) -> println("Error saving: {e.message()}") + Err(e) -> println("Error saving: {Error.message(e)}") } store } @@ -92,7 +92,7 @@ fn handle_save(store) { fn handle_load() { match io.read_file(db_path) { Err(e) -> { - println("Error loading: {e.message()}") + println("Error loading: {Error.message(e)}") println("Starting with empty store.") #{} } @@ -103,7 +103,7 @@ fn handle_load() { loaded } Err(e) -> { - println("Error parsing JSON: {e.message()}") + println("Error parsing JSON: {Error.message(e)}") println("Starting with empty store.") #{} } diff --git a/fuzz/corpus/fuzz_parser/link_checker.silt b/fuzz/corpus/fuzz_parser/link_checker.silt index 72f749e45..6ab487d7f 100644 --- a/fuzz/corpus/fuzz_parser/link_checker.silt +++ b/fuzz/corpus/fuzz_parser/link_checker.silt @@ -23,7 +23,7 @@ fn main() { let content = match io.read_file(file_path) { Ok(c) -> c Err(e) -> { - println("Error reading file: {e.message()}") + println("Error reading file: {Error.message(e)}") return panic("Cannot continue without file") } } diff --git a/fuzz/corpus/fuzz_parser/pipeline.silt b/fuzz/corpus/fuzz_parser/pipeline.silt index dda665606..bba06791e 100644 --- a/fuzz/corpus/fuzz_parser/pipeline.silt +++ b/fuzz/corpus/fuzz_parser/pipeline.silt @@ -159,7 +159,7 @@ fn main() { -- Read the log file; `return` in an Err arm bails out of main. let content = match io.read_file("examples/log.txt") { Ok(c) -> c - Err(e) -> return println("Error reading log file: {e.message()}") + Err(e) -> return println("Error reading log file: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_parser/state_machine.silt b/fuzz/corpus/fuzz_parser/state_machine.silt index 198fb9c76..385083bc0 100644 --- a/fuzz/corpus/fuzz_parser/state_machine.silt +++ b/fuzz/corpus/fuzz_parser/state_machine.silt @@ -51,7 +51,7 @@ trait Display for Event { -- Print a labeled displayable value (uses where clause) fn print_labeled(label: String, value: a) where a: Display { - println("{label}: {value.display()}") + println("{label}: {value}") } -- Print a list of displayable items with a header (uses where clause) @@ -59,7 +59,7 @@ fn print_labeled(label: String, value: a) where a: Display { fn print_items(header: String, items: List(a)) where a: Display { println(header) items - |> list.each { item -> println(" - {item.display()}") } + |> list.each { item -> println(" - {item}") } } -- Look up item info from inventory; returns (quantity, price) or None @@ -155,7 +155,7 @@ fn run_machine(events, initial_state, initial_inventory) { _ -> (state2, inventory2) } let (new_state, message, new_inv) = transition(state3, event, inventory3) - let new_log = list.append(log2, (step2, event.display(), state3, new_state, message)) + let new_log = list.append(log2, (step2, "{event}", state3, new_state, message)) (new_state, new_inv, step2 + 1, new_log) } -- If we're in Dispensing state, auto-resolve it first @@ -191,7 +191,7 @@ fn main() { _ -> "{step}" } println("[{step_str}] Event: {event_str}") - println(" {old_state.display()} -> {new_state.display()}") + println(" {old_state} -> {new_state}") println(" >> {message}") println("") } diff --git a/fuzz/corpus/fuzz_parser/time_demo.silt b/fuzz/corpus/fuzz_parser/time_demo.silt index 0efdf76db..ea780972b 100644 --- a/fuzz/corpus/fuzz_parser/time_demo.silt +++ b/fuzz/corpus/fuzz_parser/time_demo.silt @@ -6,31 +6,31 @@ fn main() { let date = time.date(2024, 3, 15) match date { Ok(d) -> println("date: {d}") - Err(e) -> println("date error: {e.message()}") + Err(e) -> println("date error: {Error.message(e)}") } let bad_date = time.date(2024, 13, 1) match bad_date { Ok(d) -> println("bad date: {d}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } let t = time.time(14, 30, 0) match t { Ok(tm) -> println("time: {tm}") - Err(e) -> println("time error: {e.message()}") + Err(e) -> println("time error: {Error.message(e)}") } let bad_time = time.time(25, 0, 0) match bad_time { Ok(tm) -> println("bad time: {tm}") - Err(e) -> println("bad time: {e.message()}") + Err(e) -> println("bad time: {Error.message(e)}") } -- Compose date + time into datetime let d = match time.date(2024, 6, 15) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let tod = match time.time(9, 30, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt = time.datetime(d, tod) println("datetime: {dt}") @@ -42,11 +42,11 @@ fn main() { -- ── Formatting ────────────────────────────────────────────────────── let dt2_date = match time.date(2024, 12, 25) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let dt2_time = match time.time(18, 0, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt2 = time.datetime(dt2_date, dt2_time) println("formatted: {dt2 @@ -57,17 +57,17 @@ fn main() { let parsed = time.parse("2024-07-04 12:00:00", "%Y-%m-%d %H:%M:%S") match parsed { Ok(dt) -> println("parsed: {dt}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } let parsed_date = time.parse_date("2024-07-04", "%Y-%m-%d") match parsed_date { Ok(d) -> println("parsed date: {d}") - Err(e) -> println("parse date error: {e.message()}") + Err(e) -> println("parse date error: {Error.message(e)}") } let bad_parse = time.parse("not-a-date", "%Y-%m-%d %H:%M:%S") match bad_parse { Ok(dt) -> println("bad parse: {dt}") - Err(e) -> println("bad parse: {e.message()}") + Err(e) -> println("bad parse: {Error.message(e)}") } -- ── Date arithmetic ───────────────────────────────────────────────── let future = today @@ -79,14 +79,14 @@ fn main() { -- Month arithmetic with end-of-month clamping let jan31 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let feb_result = jan31 |> time.add_months(1) println("Jan 31 + 1 month = {feb_result}") let mar31 = match time.date(2024, 3, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let prev = mar31 |> time.add_months(-1) @@ -122,11 +122,11 @@ fn main() { println("today is: {weekday}") let d_start = match time.date(2024, 1, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d_end = match time.date(2024, 12, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let days = time.days_between(d_start, d_end) println("days in 2024: {days}") @@ -138,11 +138,11 @@ fn main() { -- ── Comparison ────────────────────────────────────────────────────── let d1 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d2 = match time.date(2024, 2, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } println("Jan 31 < Feb 1: {d1 < d2}") println("Feb 1 > Jan 31: {d2 > d1}") diff --git a/fuzz/corpus/fuzz_parser/todo.silt b/fuzz/corpus/fuzz_parser/todo.silt index 6b7d05a98..be223ca9c 100644 --- a/fuzz/corpus/fuzz_parser/todo.silt +++ b/fuzz/corpus/fuzz_parser/todo.silt @@ -61,7 +61,7 @@ fn save_todos(todos, path) { let content = json.stringify(todos) match io.write_file(path, content) { Ok(_) -> println(" Saved {list.length(todos)} todo(s) to {path}") - Err(e) -> println(" Error saving: {e.message()}") + Err(e) -> println(" Error saving: {Error.message(e)}") } } @@ -78,13 +78,13 @@ fn load_todos(path) { todos } Err(e) -> { - println(" Error parsing: {e.message()}") + println(" Error parsing: {Error.message(e)}") [] } } } Err(e) -> { - println(" Error loading: {e.message()}") + println(" Error loading: {Error.message(e)}") [] } } diff --git a/fuzz/corpus/fuzz_parser/trait_zoo.silt b/fuzz/corpus/fuzz_parser/trait_zoo.silt index d861f0659..9181b9b2f 100644 --- a/fuzz/corpus/fuzz_parser/trait_zoo.silt +++ b/fuzz/corpus/fuzz_parser/trait_zoo.silt @@ -52,7 +52,7 @@ trait Display for Color { trait Display for Styled { fn display(self) -> String { match self { - Styled(shape, color) -> "{shape.display()} in {color.display()}" + Styled(shape, color) -> "{shape} in {color}" } } } @@ -97,7 +97,7 @@ trait Perimeter for Shape { -- Generic function with where clause fn describe(item: a) where a: Display { - item.display() + "{item}" } -- Format a float to 4 decimal places diff --git a/fuzz/corpus/fuzz_parser/traits.silt b/fuzz/corpus/fuzz_parser/traits.silt index 794b0103a..0eaae4cc1 100644 --- a/fuzz/corpus/fuzz_parser/traits.silt +++ b/fuzz/corpus/fuzz_parser/traits.silt @@ -25,7 +25,7 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") shapes - |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } diff --git a/fuzz/corpus/fuzz_roundtrip/birthdays.silt b/fuzz/corpus/fuzz_roundtrip/birthdays.silt index 5cd804dd7..9431866f5 100644 --- a/fuzz/corpus/fuzz_roundtrip/birthdays.silt +++ b/fuzz/corpus/fuzz_roundtrip/birthdays.silt @@ -47,7 +47,7 @@ fn main() { ] """, Person) { Ok(p) -> p - Err(e) -> panic("Failed to parse people: {e.message()}") + Err(e) -> panic("Failed to parse people: {Error.message(e)}") } people |> list.each { p -> diff --git a/fuzz/corpus/fuzz_roundtrip/concurrent_processor.silt b/fuzz/corpus/fuzz_roundtrip/concurrent_processor.silt index a4442b900..f6b05a6f3 100644 --- a/fuzz/corpus/fuzz_roundtrip/concurrent_processor.silt +++ b/fuzz/corpus/fuzz_roundtrip/concurrent_processor.silt @@ -101,7 +101,7 @@ fn main() { } Err(err_info) -> { let (path, err) = err_info - println("[Worker {worker_id}] FAILED {path}: {err.message()}") + println("[Worker {worker_id}] FAILED {path}: {Error.message(err)}") loop(collected + 1, successes, failures + 1) } } diff --git a/fuzz/corpus/fuzz_roundtrip/config_parser.silt b/fuzz/corpus/fuzz_roundtrip/config_parser.silt index c235a060c..ead4d6960 100644 --- a/fuzz/corpus/fuzz_roundtrip/config_parser.silt +++ b/fuzz/corpus/fuzz_roundtrip/config_parser.silt @@ -143,7 +143,7 @@ fn main() { -- Read the config file let text = match io.read_file("examples/app.conf") { Ok(t) -> t - Err(e) -> return println("Error reading examples/app.conf: {e.message()}") + Err(e) -> return println("Error reading examples/app.conf: {Error.message(e)}") } println("=== Parsing config file ===") println("") diff --git a/fuzz/corpus/fuzz_roundtrip/csv_analyzer.silt b/fuzz/corpus/fuzz_roundtrip/csv_analyzer.silt index 6d2ab00d3..4bdfc6328 100644 --- a/fuzz/corpus/fuzz_roundtrip/csv_analyzer.silt +++ b/fuzz/corpus/fuzz_roundtrip/csv_analyzer.silt @@ -112,7 +112,7 @@ fn main() { -- Read and parse CSV; bail out on IO errors with a rendered message. let content = match io.read_file("examples/data.csv") { Ok(text) -> text - Err(e) -> panic("Error reading data.csv: {e.message()}") + Err(e) -> panic("Error reading data.csv: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_roundtrip/diff_tool.silt b/fuzz/corpus/fuzz_roundtrip/diff_tool.silt index 7ec90d4b8..a4716b29c 100644 --- a/fuzz/corpus/fuzz_roundtrip/diff_tool.silt +++ b/fuzz/corpus/fuzz_roundtrip/diff_tool.silt @@ -111,11 +111,11 @@ fn main() { -- Read both files, bailing out if either is missing. let old_content = match io.read_file("examples/data/original.txt") { Ok(content) -> content - Err(e) -> panic("Error reading original.txt: {e.message()}") + Err(e) -> panic("Error reading original.txt: {Error.message(e)}") } let new_content = match io.read_file("examples/data/modified.txt") { Ok(content) -> content - Err(e) -> panic("Error reading modified.txt: {e.message()}") + Err(e) -> panic("Error reading modified.txt: {Error.message(e)}") } -- Split into lines, filter out trailing empty line from final newline let old_lines = old_content diff --git a/fuzz/corpus/fuzz_roundtrip/expr_eval.silt b/fuzz/corpus/fuzz_roundtrip/expr_eval.silt index 906d51cea..f1907aaae 100644 --- a/fuzz/corpus/fuzz_roundtrip/expr_eval.silt +++ b/fuzz/corpus/fuzz_roundtrip/expr_eval.silt @@ -20,9 +20,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -205,16 +205,16 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) let rpn_str = string.join(rpn, " ") println(" RPN: {rpn_str}") let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") println(" Depth: {depth(expr)}") @@ -225,10 +225,10 @@ fn main() { -- Demonstrate deep pattern matching println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -239,7 +239,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN println("\n=== From RPN ===\n") @@ -247,7 +247,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification println("\n=== Negative Pattern Simplification ===\n") @@ -255,7 +255,7 @@ fn main() { neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") } diff --git a/fuzz/corpus/fuzz_roundtrip/http_client.silt b/fuzz/corpus/fuzz_roundtrip/http_client.silt index 5ebaa97db..12a3ca26f 100644 --- a/fuzz/corpus/fuzz_roundtrip/http_client.silt +++ b/fuzz/corpus/fuzz_roundtrip/http_client.silt @@ -20,16 +20,16 @@ fn fetch_repos(user) { -- its caller. let resp = match http.get("https://api.github.com/users/{user}/repos") { Ok(r) -> r - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } -- The body is the bytes that arrived; JSON is text. let text = match bytes.to_string(resp.body) { Ok(text) -> text - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } match json.parse_list(text, Repo) { Ok(repos) -> Ok(repos) - Err(e) -> Err(e.message()) + Err(e) -> Err(Error.message(e)) } } diff --git a/fuzz/corpus/fuzz_roundtrip/http_server.silt b/fuzz/corpus/fuzz_roundtrip/http_server.silt index cff3c0e01..e9c253201 100644 --- a/fuzz/corpus/fuzz_roundtrip/http_server.silt +++ b/fuzz/corpus/fuzz_roundtrip/http_server.silt @@ -47,9 +47,9 @@ fn main() { (http.POST, ["todos"]) -> match bytes.to_string(req.body) { Ok(text) -> match json.parse(text, Todo) { Ok(todo) -> json_response(201, todo) - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } (http.GET, ["todos", id_str]) -> match int.parse(id_str) { Ok(id) -> json_response(200, Todo { id: id, title: "Todo {id}", done: false }) diff --git a/fuzz/corpus/fuzz_roundtrip/json_time.silt b/fuzz/corpus/fuzz_roundtrip/json_time.silt index 86ccc60c4..5c599757c 100644 --- a/fuzz/corpus/fuzz_roundtrip/json_time.silt +++ b/fuzz/corpus/fuzz_roundtrip/json_time.silt @@ -22,7 +22,7 @@ fn main() { -- Parse JSON with Date field let event = match json.parse("""{"name": "launch", "date": "2024-03-15"}""", Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("event: {event.name}") println("date: {event.date}") @@ -32,13 +32,13 @@ fn main() { -- Parse JSON with DateTime field let meeting = match json.parse("""{"title": "standup", "start": "2024-03-15T09:00:00"}""", Meeting) { Ok(m) -> m - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("meeting: {meeting.title} at {meeting.start}") -- Parse JSON with Time field let sched = match json.parse("""{"event": "lunch", "date": "2024-03-15", "time": "12:30:00"}""", Schedule) { Ok(s) -> s - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("schedule: {sched.event} on {sched.date} at {sched.time}") -- Parse a list of events @@ -50,7 +50,7 @@ fn main() { ] """, Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } events |> list.each { e -> @@ -66,6 +66,6 @@ fn main() { let bad = json.parse("""{"name": "oops", "date": "not-a-date"}""", Event) match bad { Ok(e) -> println("bad date: parsed as {e.name}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } } diff --git a/fuzz/corpus/fuzz_roundtrip/json_transform.silt b/fuzz/corpus/fuzz_roundtrip/json_transform.silt index 6d2a267a8..084edb735 100644 --- a/fuzz/corpus/fuzz_roundtrip/json_transform.silt +++ b/fuzz/corpus/fuzz_roundtrip/json_transform.silt @@ -75,7 +75,7 @@ fn main() { -- Parse the JSON dataset let employees = match json.parse_list(employee_json, Employee) { Ok(emps) -> emps - Err(e) -> panic("Failed to parse employees: {e.message()}") + Err(e) -> panic("Failed to parse employees: {Error.message(e)}") } println("=== JSON Data Pipeline ===\n") -- 1. Group by department diff --git a/fuzz/corpus/fuzz_roundtrip/kvstore.silt b/fuzz/corpus/fuzz_roundtrip/kvstore.silt index e74c39ea1..fd922cc1b 100644 --- a/fuzz/corpus/fuzz_roundtrip/kvstore.silt +++ b/fuzz/corpus/fuzz_roundtrip/kvstore.silt @@ -84,7 +84,7 @@ fn handle_save(store) { let json_str = json.stringify(store) match io.write_file(db_path, json_str) { Ok(_) -> println("OK - saved {map.length(store)} entries to {db_path}") - Err(e) -> println("Error saving: {e.message()}") + Err(e) -> println("Error saving: {Error.message(e)}") } store } @@ -92,7 +92,7 @@ fn handle_save(store) { fn handle_load() { match io.read_file(db_path) { Err(e) -> { - println("Error loading: {e.message()}") + println("Error loading: {Error.message(e)}") println("Starting with empty store.") #{} } @@ -103,7 +103,7 @@ fn handle_load() { loaded } Err(e) -> { - println("Error parsing JSON: {e.message()}") + println("Error parsing JSON: {Error.message(e)}") println("Starting with empty store.") #{} } diff --git a/fuzz/corpus/fuzz_roundtrip/link_checker.silt b/fuzz/corpus/fuzz_roundtrip/link_checker.silt index 72f749e45..6ab487d7f 100644 --- a/fuzz/corpus/fuzz_roundtrip/link_checker.silt +++ b/fuzz/corpus/fuzz_roundtrip/link_checker.silt @@ -23,7 +23,7 @@ fn main() { let content = match io.read_file(file_path) { Ok(c) -> c Err(e) -> { - println("Error reading file: {e.message()}") + println("Error reading file: {Error.message(e)}") return panic("Cannot continue without file") } } diff --git a/fuzz/corpus/fuzz_roundtrip/pipeline.silt b/fuzz/corpus/fuzz_roundtrip/pipeline.silt index dda665606..bba06791e 100644 --- a/fuzz/corpus/fuzz_roundtrip/pipeline.silt +++ b/fuzz/corpus/fuzz_roundtrip/pipeline.silt @@ -159,7 +159,7 @@ fn main() { -- Read the log file; `return` in an Err arm bails out of main. let content = match io.read_file("examples/log.txt") { Ok(c) -> c - Err(e) -> return println("Error reading log file: {e.message()}") + Err(e) -> return println("Error reading log file: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_roundtrip/state_machine.silt b/fuzz/corpus/fuzz_roundtrip/state_machine.silt index 198fb9c76..385083bc0 100644 --- a/fuzz/corpus/fuzz_roundtrip/state_machine.silt +++ b/fuzz/corpus/fuzz_roundtrip/state_machine.silt @@ -51,7 +51,7 @@ trait Display for Event { -- Print a labeled displayable value (uses where clause) fn print_labeled(label: String, value: a) where a: Display { - println("{label}: {value.display()}") + println("{label}: {value}") } -- Print a list of displayable items with a header (uses where clause) @@ -59,7 +59,7 @@ fn print_labeled(label: String, value: a) where a: Display { fn print_items(header: String, items: List(a)) where a: Display { println(header) items - |> list.each { item -> println(" - {item.display()}") } + |> list.each { item -> println(" - {item}") } } -- Look up item info from inventory; returns (quantity, price) or None @@ -155,7 +155,7 @@ fn run_machine(events, initial_state, initial_inventory) { _ -> (state2, inventory2) } let (new_state, message, new_inv) = transition(state3, event, inventory3) - let new_log = list.append(log2, (step2, event.display(), state3, new_state, message)) + let new_log = list.append(log2, (step2, "{event}", state3, new_state, message)) (new_state, new_inv, step2 + 1, new_log) } -- If we're in Dispensing state, auto-resolve it first @@ -191,7 +191,7 @@ fn main() { _ -> "{step}" } println("[{step_str}] Event: {event_str}") - println(" {old_state.display()} -> {new_state.display()}") + println(" {old_state} -> {new_state}") println(" >> {message}") println("") } diff --git a/fuzz/corpus/fuzz_roundtrip/time_demo.silt b/fuzz/corpus/fuzz_roundtrip/time_demo.silt index 0efdf76db..ea780972b 100644 --- a/fuzz/corpus/fuzz_roundtrip/time_demo.silt +++ b/fuzz/corpus/fuzz_roundtrip/time_demo.silt @@ -6,31 +6,31 @@ fn main() { let date = time.date(2024, 3, 15) match date { Ok(d) -> println("date: {d}") - Err(e) -> println("date error: {e.message()}") + Err(e) -> println("date error: {Error.message(e)}") } let bad_date = time.date(2024, 13, 1) match bad_date { Ok(d) -> println("bad date: {d}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } let t = time.time(14, 30, 0) match t { Ok(tm) -> println("time: {tm}") - Err(e) -> println("time error: {e.message()}") + Err(e) -> println("time error: {Error.message(e)}") } let bad_time = time.time(25, 0, 0) match bad_time { Ok(tm) -> println("bad time: {tm}") - Err(e) -> println("bad time: {e.message()}") + Err(e) -> println("bad time: {Error.message(e)}") } -- Compose date + time into datetime let d = match time.date(2024, 6, 15) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let tod = match time.time(9, 30, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt = time.datetime(d, tod) println("datetime: {dt}") @@ -42,11 +42,11 @@ fn main() { -- ── Formatting ────────────────────────────────────────────────────── let dt2_date = match time.date(2024, 12, 25) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let dt2_time = match time.time(18, 0, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt2 = time.datetime(dt2_date, dt2_time) println("formatted: {dt2 @@ -57,17 +57,17 @@ fn main() { let parsed = time.parse("2024-07-04 12:00:00", "%Y-%m-%d %H:%M:%S") match parsed { Ok(dt) -> println("parsed: {dt}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } let parsed_date = time.parse_date("2024-07-04", "%Y-%m-%d") match parsed_date { Ok(d) -> println("parsed date: {d}") - Err(e) -> println("parse date error: {e.message()}") + Err(e) -> println("parse date error: {Error.message(e)}") } let bad_parse = time.parse("not-a-date", "%Y-%m-%d %H:%M:%S") match bad_parse { Ok(dt) -> println("bad parse: {dt}") - Err(e) -> println("bad parse: {e.message()}") + Err(e) -> println("bad parse: {Error.message(e)}") } -- ── Date arithmetic ───────────────────────────────────────────────── let future = today @@ -79,14 +79,14 @@ fn main() { -- Month arithmetic with end-of-month clamping let jan31 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let feb_result = jan31 |> time.add_months(1) println("Jan 31 + 1 month = {feb_result}") let mar31 = match time.date(2024, 3, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let prev = mar31 |> time.add_months(-1) @@ -122,11 +122,11 @@ fn main() { println("today is: {weekday}") let d_start = match time.date(2024, 1, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d_end = match time.date(2024, 12, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let days = time.days_between(d_start, d_end) println("days in 2024: {days}") @@ -138,11 +138,11 @@ fn main() { -- ── Comparison ────────────────────────────────────────────────────── let d1 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d2 = match time.date(2024, 2, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } println("Jan 31 < Feb 1: {d1 < d2}") println("Feb 1 > Jan 31: {d2 > d1}") diff --git a/fuzz/corpus/fuzz_roundtrip/todo.silt b/fuzz/corpus/fuzz_roundtrip/todo.silt index 6b7d05a98..be223ca9c 100644 --- a/fuzz/corpus/fuzz_roundtrip/todo.silt +++ b/fuzz/corpus/fuzz_roundtrip/todo.silt @@ -61,7 +61,7 @@ fn save_todos(todos, path) { let content = json.stringify(todos) match io.write_file(path, content) { Ok(_) -> println(" Saved {list.length(todos)} todo(s) to {path}") - Err(e) -> println(" Error saving: {e.message()}") + Err(e) -> println(" Error saving: {Error.message(e)}") } } @@ -78,13 +78,13 @@ fn load_todos(path) { todos } Err(e) -> { - println(" Error parsing: {e.message()}") + println(" Error parsing: {Error.message(e)}") [] } } } Err(e) -> { - println(" Error loading: {e.message()}") + println(" Error loading: {Error.message(e)}") [] } } diff --git a/fuzz/corpus/fuzz_roundtrip/trait_zoo.silt b/fuzz/corpus/fuzz_roundtrip/trait_zoo.silt index d861f0659..9181b9b2f 100644 --- a/fuzz/corpus/fuzz_roundtrip/trait_zoo.silt +++ b/fuzz/corpus/fuzz_roundtrip/trait_zoo.silt @@ -52,7 +52,7 @@ trait Display for Color { trait Display for Styled { fn display(self) -> String { match self { - Styled(shape, color) -> "{shape.display()} in {color.display()}" + Styled(shape, color) -> "{shape} in {color}" } } } @@ -97,7 +97,7 @@ trait Perimeter for Shape { -- Generic function with where clause fn describe(item: a) where a: Display { - item.display() + "{item}" } -- Format a float to 4 decimal places diff --git a/fuzz/corpus/fuzz_roundtrip/traits.silt b/fuzz/corpus/fuzz_roundtrip/traits.silt index 794b0103a..0eaae4cc1 100644 --- a/fuzz/corpus/fuzz_roundtrip/traits.silt +++ b/fuzz/corpus/fuzz_roundtrip/traits.silt @@ -25,7 +25,7 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") shapes - |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } diff --git a/fuzz/corpus/fuzz_run/run_records_traits.silt b/fuzz/corpus/fuzz_run/run_records_traits.silt index 58d24d9b9..04ca9cdd1 100644 --- a/fuzz/corpus/fuzz_run/run_records_traits.silt +++ b/fuzz/corpus/fuzz_run/run_records_traits.silt @@ -30,6 +30,6 @@ fn main() { println("{p} {q}") println([p, q]) let shapes = [Circle(2), Rect(3, 4)] - println(list.map(shapes) { s -> s.area() }) + println(list.map(shapes) { s -> Area.area(s) }) q.x + q.y } diff --git a/fuzz/corpus/fuzz_typechecker/birthdays.silt b/fuzz/corpus/fuzz_typechecker/birthdays.silt index 5cd804dd7..9431866f5 100644 --- a/fuzz/corpus/fuzz_typechecker/birthdays.silt +++ b/fuzz/corpus/fuzz_typechecker/birthdays.silt @@ -47,7 +47,7 @@ fn main() { ] """, Person) { Ok(p) -> p - Err(e) -> panic("Failed to parse people: {e.message()}") + Err(e) -> panic("Failed to parse people: {Error.message(e)}") } people |> list.each { p -> diff --git a/fuzz/corpus/fuzz_typechecker/concurrent_processor.silt b/fuzz/corpus/fuzz_typechecker/concurrent_processor.silt index a4442b900..f6b05a6f3 100644 --- a/fuzz/corpus/fuzz_typechecker/concurrent_processor.silt +++ b/fuzz/corpus/fuzz_typechecker/concurrent_processor.silt @@ -101,7 +101,7 @@ fn main() { } Err(err_info) -> { let (path, err) = err_info - println("[Worker {worker_id}] FAILED {path}: {err.message()}") + println("[Worker {worker_id}] FAILED {path}: {Error.message(err)}") loop(collected + 1, successes, failures + 1) } } diff --git a/fuzz/corpus/fuzz_typechecker/config_parser.silt b/fuzz/corpus/fuzz_typechecker/config_parser.silt index c235a060c..ead4d6960 100644 --- a/fuzz/corpus/fuzz_typechecker/config_parser.silt +++ b/fuzz/corpus/fuzz_typechecker/config_parser.silt @@ -143,7 +143,7 @@ fn main() { -- Read the config file let text = match io.read_file("examples/app.conf") { Ok(t) -> t - Err(e) -> return println("Error reading examples/app.conf: {e.message()}") + Err(e) -> return println("Error reading examples/app.conf: {Error.message(e)}") } println("=== Parsing config file ===") println("") diff --git a/fuzz/corpus/fuzz_typechecker/csv_analyzer.silt b/fuzz/corpus/fuzz_typechecker/csv_analyzer.silt index 6d2ab00d3..4bdfc6328 100644 --- a/fuzz/corpus/fuzz_typechecker/csv_analyzer.silt +++ b/fuzz/corpus/fuzz_typechecker/csv_analyzer.silt @@ -112,7 +112,7 @@ fn main() { -- Read and parse CSV; bail out on IO errors with a rendered message. let content = match io.read_file("examples/data.csv") { Ok(text) -> text - Err(e) -> panic("Error reading data.csv: {e.message()}") + Err(e) -> panic("Error reading data.csv: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_typechecker/diff_tool.silt b/fuzz/corpus/fuzz_typechecker/diff_tool.silt index 7ec90d4b8..a4716b29c 100644 --- a/fuzz/corpus/fuzz_typechecker/diff_tool.silt +++ b/fuzz/corpus/fuzz_typechecker/diff_tool.silt @@ -111,11 +111,11 @@ fn main() { -- Read both files, bailing out if either is missing. let old_content = match io.read_file("examples/data/original.txt") { Ok(content) -> content - Err(e) -> panic("Error reading original.txt: {e.message()}") + Err(e) -> panic("Error reading original.txt: {Error.message(e)}") } let new_content = match io.read_file("examples/data/modified.txt") { Ok(content) -> content - Err(e) -> panic("Error reading modified.txt: {e.message()}") + Err(e) -> panic("Error reading modified.txt: {Error.message(e)}") } -- Split into lines, filter out trailing empty line from final newline let old_lines = old_content diff --git a/fuzz/corpus/fuzz_typechecker/expr_eval.silt b/fuzz/corpus/fuzz_typechecker/expr_eval.silt index 906d51cea..f1907aaae 100644 --- a/fuzz/corpus/fuzz_typechecker/expr_eval.silt +++ b/fuzz/corpus/fuzz_typechecker/expr_eval.silt @@ -20,9 +20,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -205,16 +205,16 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) let rpn_str = string.join(rpn, " ") println(" RPN: {rpn_str}") let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") println(" Depth: {depth(expr)}") @@ -225,10 +225,10 @@ fn main() { -- Demonstrate deep pattern matching println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -239,7 +239,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN println("\n=== From RPN ===\n") @@ -247,7 +247,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification println("\n=== Negative Pattern Simplification ===\n") @@ -255,7 +255,7 @@ fn main() { neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") } diff --git a/fuzz/corpus/fuzz_typechecker/http_client.silt b/fuzz/corpus/fuzz_typechecker/http_client.silt index 5ebaa97db..12a3ca26f 100644 --- a/fuzz/corpus/fuzz_typechecker/http_client.silt +++ b/fuzz/corpus/fuzz_typechecker/http_client.silt @@ -20,16 +20,16 @@ fn fetch_repos(user) { -- its caller. let resp = match http.get("https://api.github.com/users/{user}/repos") { Ok(r) -> r - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } -- The body is the bytes that arrived; JSON is text. let text = match bytes.to_string(resp.body) { Ok(text) -> text - Err(e) -> return Err(e.message()) + Err(e) -> return Err(Error.message(e)) } match json.parse_list(text, Repo) { Ok(repos) -> Ok(repos) - Err(e) -> Err(e.message()) + Err(e) -> Err(Error.message(e)) } } diff --git a/fuzz/corpus/fuzz_typechecker/http_server.silt b/fuzz/corpus/fuzz_typechecker/http_server.silt index cff3c0e01..e9c253201 100644 --- a/fuzz/corpus/fuzz_typechecker/http_server.silt +++ b/fuzz/corpus/fuzz_typechecker/http_server.silt @@ -47,9 +47,9 @@ fn main() { (http.POST, ["todos"]) -> match bytes.to_string(req.body) { Ok(text) -> match json.parse(text, Todo) { Ok(todo) -> json_response(201, todo) - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } - Err(e) -> json_response(400, #{ "error": e.message() }) + Err(e) -> json_response(400, #{ "error": Error.message(e) }) } (http.GET, ["todos", id_str]) -> match int.parse(id_str) { Ok(id) -> json_response(200, Todo { id: id, title: "Todo {id}", done: false }) diff --git a/fuzz/corpus/fuzz_typechecker/json_time.silt b/fuzz/corpus/fuzz_typechecker/json_time.silt index 86ccc60c4..5c599757c 100644 --- a/fuzz/corpus/fuzz_typechecker/json_time.silt +++ b/fuzz/corpus/fuzz_typechecker/json_time.silt @@ -22,7 +22,7 @@ fn main() { -- Parse JSON with Date field let event = match json.parse("""{"name": "launch", "date": "2024-03-15"}""", Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("event: {event.name}") println("date: {event.date}") @@ -32,13 +32,13 @@ fn main() { -- Parse JSON with DateTime field let meeting = match json.parse("""{"title": "standup", "start": "2024-03-15T09:00:00"}""", Meeting) { Ok(m) -> m - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("meeting: {meeting.title} at {meeting.start}") -- Parse JSON with Time field let sched = match json.parse("""{"event": "lunch", "date": "2024-03-15", "time": "12:30:00"}""", Schedule) { Ok(s) -> s - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("schedule: {sched.event} on {sched.date} at {sched.time}") -- Parse a list of events @@ -50,7 +50,7 @@ fn main() { ] """, Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } events |> list.each { e -> @@ -66,6 +66,6 @@ fn main() { let bad = json.parse("""{"name": "oops", "date": "not-a-date"}""", Event) match bad { Ok(e) -> println("bad date: parsed as {e.name}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } } diff --git a/fuzz/corpus/fuzz_typechecker/json_transform.silt b/fuzz/corpus/fuzz_typechecker/json_transform.silt index 6d2a267a8..084edb735 100644 --- a/fuzz/corpus/fuzz_typechecker/json_transform.silt +++ b/fuzz/corpus/fuzz_typechecker/json_transform.silt @@ -75,7 +75,7 @@ fn main() { -- Parse the JSON dataset let employees = match json.parse_list(employee_json, Employee) { Ok(emps) -> emps - Err(e) -> panic("Failed to parse employees: {e.message()}") + Err(e) -> panic("Failed to parse employees: {Error.message(e)}") } println("=== JSON Data Pipeline ===\n") -- 1. Group by department diff --git a/fuzz/corpus/fuzz_typechecker/kvstore.silt b/fuzz/corpus/fuzz_typechecker/kvstore.silt index e74c39ea1..fd922cc1b 100644 --- a/fuzz/corpus/fuzz_typechecker/kvstore.silt +++ b/fuzz/corpus/fuzz_typechecker/kvstore.silt @@ -84,7 +84,7 @@ fn handle_save(store) { let json_str = json.stringify(store) match io.write_file(db_path, json_str) { Ok(_) -> println("OK - saved {map.length(store)} entries to {db_path}") - Err(e) -> println("Error saving: {e.message()}") + Err(e) -> println("Error saving: {Error.message(e)}") } store } @@ -92,7 +92,7 @@ fn handle_save(store) { fn handle_load() { match io.read_file(db_path) { Err(e) -> { - println("Error loading: {e.message()}") + println("Error loading: {Error.message(e)}") println("Starting with empty store.") #{} } @@ -103,7 +103,7 @@ fn handle_load() { loaded } Err(e) -> { - println("Error parsing JSON: {e.message()}") + println("Error parsing JSON: {Error.message(e)}") println("Starting with empty store.") #{} } diff --git a/fuzz/corpus/fuzz_typechecker/link_checker.silt b/fuzz/corpus/fuzz_typechecker/link_checker.silt index 72f749e45..6ab487d7f 100644 --- a/fuzz/corpus/fuzz_typechecker/link_checker.silt +++ b/fuzz/corpus/fuzz_typechecker/link_checker.silt @@ -23,7 +23,7 @@ fn main() { let content = match io.read_file(file_path) { Ok(c) -> c Err(e) -> { - println("Error reading file: {e.message()}") + println("Error reading file: {Error.message(e)}") return panic("Cannot continue without file") } } diff --git a/fuzz/corpus/fuzz_typechecker/pipeline.silt b/fuzz/corpus/fuzz_typechecker/pipeline.silt index dda665606..bba06791e 100644 --- a/fuzz/corpus/fuzz_typechecker/pipeline.silt +++ b/fuzz/corpus/fuzz_typechecker/pipeline.silt @@ -159,7 +159,7 @@ fn main() { -- Read the log file; `return` in an Err arm bails out of main. let content = match io.read_file("examples/log.txt") { Ok(c) -> c - Err(e) -> return println("Error reading log file: {e.message()}") + Err(e) -> return println("Error reading log file: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/fuzz/corpus/fuzz_typechecker/state_machine.silt b/fuzz/corpus/fuzz_typechecker/state_machine.silt index 198fb9c76..385083bc0 100644 --- a/fuzz/corpus/fuzz_typechecker/state_machine.silt +++ b/fuzz/corpus/fuzz_typechecker/state_machine.silt @@ -51,7 +51,7 @@ trait Display for Event { -- Print a labeled displayable value (uses where clause) fn print_labeled(label: String, value: a) where a: Display { - println("{label}: {value.display()}") + println("{label}: {value}") } -- Print a list of displayable items with a header (uses where clause) @@ -59,7 +59,7 @@ fn print_labeled(label: String, value: a) where a: Display { fn print_items(header: String, items: List(a)) where a: Display { println(header) items - |> list.each { item -> println(" - {item.display()}") } + |> list.each { item -> println(" - {item}") } } -- Look up item info from inventory; returns (quantity, price) or None @@ -155,7 +155,7 @@ fn run_machine(events, initial_state, initial_inventory) { _ -> (state2, inventory2) } let (new_state, message, new_inv) = transition(state3, event, inventory3) - let new_log = list.append(log2, (step2, event.display(), state3, new_state, message)) + let new_log = list.append(log2, (step2, "{event}", state3, new_state, message)) (new_state, new_inv, step2 + 1, new_log) } -- If we're in Dispensing state, auto-resolve it first @@ -191,7 +191,7 @@ fn main() { _ -> "{step}" } println("[{step_str}] Event: {event_str}") - println(" {old_state.display()} -> {new_state.display()}") + println(" {old_state} -> {new_state}") println(" >> {message}") println("") } diff --git a/fuzz/corpus/fuzz_typechecker/time_demo.silt b/fuzz/corpus/fuzz_typechecker/time_demo.silt index 0efdf76db..ea780972b 100644 --- a/fuzz/corpus/fuzz_typechecker/time_demo.silt +++ b/fuzz/corpus/fuzz_typechecker/time_demo.silt @@ -6,31 +6,31 @@ fn main() { let date = time.date(2024, 3, 15) match date { Ok(d) -> println("date: {d}") - Err(e) -> println("date error: {e.message()}") + Err(e) -> println("date error: {Error.message(e)}") } let bad_date = time.date(2024, 13, 1) match bad_date { Ok(d) -> println("bad date: {d}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } let t = time.time(14, 30, 0) match t { Ok(tm) -> println("time: {tm}") - Err(e) -> println("time error: {e.message()}") + Err(e) -> println("time error: {Error.message(e)}") } let bad_time = time.time(25, 0, 0) match bad_time { Ok(tm) -> println("bad time: {tm}") - Err(e) -> println("bad time: {e.message()}") + Err(e) -> println("bad time: {Error.message(e)}") } -- Compose date + time into datetime let d = match time.date(2024, 6, 15) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let tod = match time.time(9, 30, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt = time.datetime(d, tod) println("datetime: {dt}") @@ -42,11 +42,11 @@ fn main() { -- ── Formatting ────────────────────────────────────────────────────── let dt2_date = match time.date(2024, 12, 25) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let dt2_time = match time.time(18, 0, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt2 = time.datetime(dt2_date, dt2_time) println("formatted: {dt2 @@ -57,17 +57,17 @@ fn main() { let parsed = time.parse("2024-07-04 12:00:00", "%Y-%m-%d %H:%M:%S") match parsed { Ok(dt) -> println("parsed: {dt}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } let parsed_date = time.parse_date("2024-07-04", "%Y-%m-%d") match parsed_date { Ok(d) -> println("parsed date: {d}") - Err(e) -> println("parse date error: {e.message()}") + Err(e) -> println("parse date error: {Error.message(e)}") } let bad_parse = time.parse("not-a-date", "%Y-%m-%d %H:%M:%S") match bad_parse { Ok(dt) -> println("bad parse: {dt}") - Err(e) -> println("bad parse: {e.message()}") + Err(e) -> println("bad parse: {Error.message(e)}") } -- ── Date arithmetic ───────────────────────────────────────────────── let future = today @@ -79,14 +79,14 @@ fn main() { -- Month arithmetic with end-of-month clamping let jan31 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let feb_result = jan31 |> time.add_months(1) println("Jan 31 + 1 month = {feb_result}") let mar31 = match time.date(2024, 3, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let prev = mar31 |> time.add_months(-1) @@ -122,11 +122,11 @@ fn main() { println("today is: {weekday}") let d_start = match time.date(2024, 1, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d_end = match time.date(2024, 12, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let days = time.days_between(d_start, d_end) println("days in 2024: {days}") @@ -138,11 +138,11 @@ fn main() { -- ── Comparison ────────────────────────────────────────────────────── let d1 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d2 = match time.date(2024, 2, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } println("Jan 31 < Feb 1: {d1 < d2}") println("Feb 1 > Jan 31: {d2 > d1}") diff --git a/fuzz/corpus/fuzz_typechecker/todo.silt b/fuzz/corpus/fuzz_typechecker/todo.silt index 6b7d05a98..be223ca9c 100644 --- a/fuzz/corpus/fuzz_typechecker/todo.silt +++ b/fuzz/corpus/fuzz_typechecker/todo.silt @@ -61,7 +61,7 @@ fn save_todos(todos, path) { let content = json.stringify(todos) match io.write_file(path, content) { Ok(_) -> println(" Saved {list.length(todos)} todo(s) to {path}") - Err(e) -> println(" Error saving: {e.message()}") + Err(e) -> println(" Error saving: {Error.message(e)}") } } @@ -78,13 +78,13 @@ fn load_todos(path) { todos } Err(e) -> { - println(" Error parsing: {e.message()}") + println(" Error parsing: {Error.message(e)}") [] } } } Err(e) -> { - println(" Error loading: {e.message()}") + println(" Error loading: {Error.message(e)}") [] } } diff --git a/fuzz/corpus/fuzz_typechecker/trait_zoo.silt b/fuzz/corpus/fuzz_typechecker/trait_zoo.silt index d861f0659..9181b9b2f 100644 --- a/fuzz/corpus/fuzz_typechecker/trait_zoo.silt +++ b/fuzz/corpus/fuzz_typechecker/trait_zoo.silt @@ -52,7 +52,7 @@ trait Display for Color { trait Display for Styled { fn display(self) -> String { match self { - Styled(shape, color) -> "{shape.display()} in {color.display()}" + Styled(shape, color) -> "{shape} in {color}" } } } @@ -97,7 +97,7 @@ trait Perimeter for Shape { -- Generic function with where clause fn describe(item: a) where a: Display { - item.display() + "{item}" } -- Format a float to 4 decimal places diff --git a/fuzz/corpus/fuzz_typechecker/traits.silt b/fuzz/corpus/fuzz_typechecker/traits.silt index 794b0103a..0eaae4cc1 100644 --- a/fuzz/corpus/fuzz_typechecker/traits.silt +++ b/fuzz/corpus/fuzz_typechecker/traits.silt @@ -25,7 +25,7 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") shapes - |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } diff --git a/src/ast.rs b/src/ast.rs index 54ed106b1..e7975f5f7 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -18,12 +18,16 @@ pub struct Expr { pub res: Option, /// What a field access on a value means, filled in by the /// typechecker when the types are final: the compiler emits what it - /// says. `None` elsewhere (and on `m.f`, `Type.method`, a variant: - /// those are names, and `res` says what they name). + /// says; on `Trait.method`, the method the call reaches. `None` + /// elsewhere (and on `m.f`, `Type.method`, a variant: those are + /// names, and `res` says what they name). pub sel: Option, } -/// What `recv.name`, on a value, means. +/// What `recv.name` means: on a value, a field; `Tr.name`, a method +/// called through its trait, for the type of its argument of type +/// `Self` (the receiver); on a type held in a value (`a.empty()` for a +/// `type a`), a method that makes a value of it. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Selection { /// The record's field `name`. @@ -31,21 +35,21 @@ pub enum Selection { /// In a call, `recv.name(args)`: the function the record's field /// `name` holds, called with `args`. FieldCall, - /// In a call: the method `name` of the impl of the trait `tr` for - /// the type `ty`, the receiver's, called with the receiver and - /// `args`. + /// The method `name` of the impl of the trait `tr` for the type + /// `ty`, the receiver's. Impl { tr: crate::defs::TraitId, ty: crate::defs::TypeId, }, - /// In a call: the method `name` of the builtin trait `tr` - /// (Display, Equal, Compare, Hash) for a receiver whose type has no - /// written impl of it: the type has the trait by its structure. + /// The method `name` of the builtin trait `tr` (Compare, Hash, + /// Error, json's) for a receiver whose type has no written impl of + /// it: the VM's own. Native { tr: crate::defs::TraitId }, - /// In a call: the method `name` of the trait `tr`, for a receiver - /// whose type is known only where the code runs (a type variable - /// bounded by the trait; a type passed as a value). - Dynamic { tr: crate::defs::TraitId }, + /// The method `name` of the trait `tr`, for a receiver whose type is + /// known only where the code runs (a type variable bounded by the + /// trait; a type passed as a value). The receiver is the argument + /// `at` of a call through the trait: its first of type `Self`. + Dynamic { tr: crate::defs::TraitId, at: u8 }, } impl Expr { diff --git a/src/builtins/data.rs b/src/builtins/data.rs index 0e6412863..ad28cf66c 100644 --- a/src/builtins/data.rs +++ b/src/builtins/data.rs @@ -462,7 +462,7 @@ mod tests { /// a handle has none. #[test] fn a_builtin_type_has_json_encode_when_the_writer_has_a_json_form_for_it() { - let (impls, _) = crate::typechecker::__trait_init_fingerprint_check_program(); + let impls = crate::typechecker::__trait_init_fingerprint_check_program(); let encode: BTreeSet<&str> = impls .iter() .filter_map(|stamp| stamp.strip_prefix("Encode:")) diff --git a/src/bytecode/ops.rs b/src/bytecode/ops.rs index f552cd3b1..90aa8da32 100644 --- a/src/bytecode/ops.rs +++ b/src/bytecode/ops.rs @@ -1031,12 +1031,14 @@ ops! { /// impl of the trait `of` names (see /// [`Globals::call_method`](super::Globals::call_method)) for the /// receiver's type, else the builtin trait's native method; call it - /// with the top `argc` values, the receiver first. - CallMethod { method: Method, argc: U8("arguments of a method call, the receiver included"), of: Trait } => pops argc, pushes 1; + /// with the top `argc` values. The receiver is the argument `at` of + /// them (the first of type `Self`: the first, but for a method whose + /// `Self` parameter comes later). + CallMethod { method: Method, argc: U8("arguments of a method call, the receiver included"), of: Trait, at: U8("the argument a method call finds its method by") } => pops argc, pushes 1; /// `CallMethod` in tail position: a method that is a closure runs /// in the current frame. Followed by `Return`, which returns the /// result of any other. - TailCallMethod { method: Method, argc: U8("arguments of a method call, the receiver included"), of: Trait } => pops argc, pushes 1; + TailCallMethod { method: Method, argc: U8("arguments of a method call, the receiver included"), of: Trait, at: U8("the argument a method call finds its method by") } => pops argc, pushes 1; /// Move TOS down to the frame's slot `slot` and drop every value /// that was above that slot: pop TOS, cut the frame back to `slot` diff --git a/src/bytecode/verify.rs b/src/bytecode/verify.rs index 4fe146bd9..b5f2791b9 100644 --- a/src/bytecode/verify.rs +++ b/src/bytecode/verify.rs @@ -361,6 +361,13 @@ fn check( Instr::CallMethod { argc: 0, .. } | Instr::TailCallMethod { argc: 0, .. } => { return fail(format!("`{op}` has no receiver")); } + Instr::CallMethod { argc, at, .. } | Instr::TailCallMethod { argc, at, .. } + if at >= argc => + { + return fail(format!( + "`{op}` finds its method by argument {at} of {argc}" + )); + } Instr::CallBuiltin { builtin: id, argc } => { // (The operand was checked above: it is a row.) if let Ok(row) = builtin(op, id) { @@ -661,6 +668,7 @@ mod tests { 1, lo, hi, + 0, op(Op::Return), ]; let function = Function::unverified(0, 0, code, vec![Value::String("foo".into())]); @@ -692,7 +700,7 @@ mod tests { #[test] fn bad_13_method_call_without_a_receiver() { let [lo, hi] = 0u16.to_le_bytes(); - let code = vec![op(Op::CallMethod), 0, 0, 0, lo, hi, op(Op::Return)]; + let code = vec![op(Op::CallMethod), 0, 0, 0, lo, hi, 0, op(Op::Return)]; assert_eq!( rejected(code, vec![Value::String("foo".into())]), "at offset 0: `CallMethod` has no receiver" @@ -706,12 +714,29 @@ mod tests { 5, lo, hi, + 0, op(Op::Return), ]; assert_eq!( rejected(code, vec![Value::String("foo".into())]), "at offset 1: `CallMethod` takes 5 values off a frame of 1" ); + // And by an argument it is not given. + let code = vec![ + op(Op::Unit), + op(Op::CallMethod), + 0, + 0, + 1, + lo, + hi, + 1, + op(Op::Return), + ]; + assert_eq!( + rejected(code, vec![Value::String("foo".into())]), + "at offset 1: `CallMethod` finds its method by argument 1 of 1" + ); } #[test] diff --git a/src/compiler/mod.rs b/src/compiler/mod.rs index e4b5203f6..aa11bfa05 100644 --- a/src/compiler/mod.rs +++ b/src/compiler/mod.rs @@ -141,14 +141,6 @@ struct Local { // ── Compiler errors ───────────────────────────────────────────────── -/// Whether the method `method` of the trait `t`, one the VM has for -/// every type, takes no value of the type: `decode` of `json.Decode`, -/// called on a type (`T.decode(v)`) with the type's descriptor as the -/// receiver. -fn takes_no_self(t: crate::defs::TraitId, method: Symbol) -> bool { - crate::defs::builtin_trait_id("Decode") == Some(t) && resolve(method) == "decode" -} - /// A defect in silt: the program reached the compiler with an error the /// typechecker reports (a builtin module used without an import, a /// `loop(...)` outside a loop or with the wrong number of arguments). The @@ -1334,46 +1326,79 @@ impl<'a> Compiler<'a> { self.emit(Asm::Constant { k: idx }, span)?; } - // `Int.display`, `Pt.compare` as a value, a method the VM has - // natively for the type: the function `{ a -> a.display() }` - // (`{ a, b -> a.compare(b) }` for the two-argument methods). - // The program wrote no closure there: the function has the - // method's name, `Int.display`, as a written method has. + // `Tr.m` as a value: the method of the one impl the checker + // selected, or the function `{ a, b -> Tr.m(a, b) }`, which + // finds it where it runs. The program wrote no closure there: + // the function has the method's name, `Tr.m`. + ExprKind::FieldAccess(of, method, _) if self.res_trait(of.res).is_some() => { + let tr = self.res_trait(of.res).expect("a trait"); + if let Some(crate::ast::Selection::Impl { tr, ty }) = expr.sel + && let Some(slot) = self.globals.method(tr, ty, &resolve(*method)) + { + self.emit(Asm::GetGlobal { slot }, span)?; + } else { + let arity = match &expr.ty { + Some(Type::Fun(params, _)) => params.len(), + _ => return Err(checker_missed(span, "a trait method of no type")), + }; + let names: Vec = + (0..arity).map(|k| intern(&format!("__arg{k}__"))).collect(); + let ident = |name: Symbol| Expr::new(ExprKind::Ident(name), span); + let call = Expr::new( + ExprKind::Call( + Box::new(expr.clone()), + names.iter().map(|n| ident(*n)).collect(), + ), + span, + ); + let lambda = Expr::new( + ExprKind::Lambda { + params: names + .iter() + .map(|n| crate::ast::Param { + kind: crate::ast::ParamKind::Data, + pattern: crate::ast::Pattern::new( + crate::ast::PatternKind::Ident(*n), + span, + ), + ty: None, + }) + .collect(), + body: Box::new(call), + }, + span, + ); + let method_name = format!("{}.{method}", self.units.defs.get(tr.0).name); + let around = self + .contexts + .last_mut() + .map(|context| std::mem::replace(&mut context.closures, method_name)); + let compiled = self.compile_expr(&lambda); + if let (Some(context), Some(around)) = (self.contexts.last_mut(), around) { + context.closures = around; + } + compiled?; + } + } + + // `T.decode` as a value, a method the VM has natively for the + // type: the function `{ v -> T.decode(v) }`. The program wrote + // no closure there: the function has the method's name, + // `T.decode`, as a written method has. ExprKind::FieldAccess(of, method, _) - if let Some(TypeMember::Native(tr)) = self.type_member(expr)? => + if let Some(TypeMember::Native(_)) = self.type_member(expr)? => { let ty = match &of.kind { ExprKind::Ident(ty) | ExprKind::FieldAccess(_, ty, _) => *ty, _ => return Err(checker_missed(span, "a method of no named type")), }; let method_name = format!("{ty}.{method}"); - let names: &[&str] = match resolve(*method).as_str() { - "compare" | "equal" => &["__self__", "__other__"], - "decode" => &["__value__"], - _ => &["__self__"], - }; + let names: &[&str] = &["__value__"]; let ident = |name: &str| Expr::new(ExprKind::Ident(intern(name)), span); - let call = match takes_no_self(tr, *method) { - // `T.decode` as a value: `{ v -> T.decode(v) }`. - true => Expr::new( - ExprKind::Call(Box::new(expr.clone()), vec![ident(names[0])]), - span, - ), - false => { - let mut access = Expr::new( - ExprKind::FieldAccess(Box::new(ident(names[0])), *method, span), - span, - ); - access.sel = Some(crate::ast::Selection::Native { tr }); - Expr::new( - ExprKind::Call( - Box::new(access), - names[1..].iter().map(|n| ident(n)).collect(), - ), - span, - ) - } - }; + let call = Expr::new( + ExprKind::Call(Box::new(expr.clone()), vec![ident(names[0])]), + span, + ); let lambda = Expr::new( ExprKind::Lambda { params: names @@ -1929,9 +1954,11 @@ impl<'a> Compiler<'a> { self.emit(Asm::CallBuiltin { builtin, argc }, span)?; } else if let ExprKind::FieldAccess(receiver, method, _) = &callee.kind { let member = self.type_member(callee)?; - if let Some(TypeMember::Native(t)) = member - && takes_no_self(t, *method) - { + if self.res_trait(receiver.res).is_some() { + // `Tr.m(args)`: the method of the impl the checker + // selected for the type of the arguments. + self.compile_trait_call(callee, *method, args, span, tail)?; + } else if let Some(TypeMember::Native(t)) = member { // `T.decode(v)`: the VM's method of the type, which takes // no value of it; the type's descriptor chooses it. let Some(descriptor) = self.type_value(receiver.res) else { @@ -1940,19 +1967,7 @@ impl<'a> Compiler<'a> { let idx = self.add_constant(descriptor, span)?; self.emit(Asm::Constant { k: idx }, span)?; self.compile_operands(args.iter().copied())?; - self.emit_call_method(*method, args.len() + 1, t, tail, span)?; - } else if let Some(TypeMember::Native(t)) = member { - // `Int.display(1)`, `Pt.compare(a, b)`: a method the VM - // has natively for the type, not a global; the first - // argument is the receiver. - if args.is_empty() { - return Err(checker_missed( - span, - &format!("the call of '{method}' through its type with no receiver"), - )); - } - self.compile_operands(args.iter().copied())?; - self.emit_call_method(*method, args.len(), t, tail, span)?; + self.emit_call_method(*method, args.len() + 1, t, 0, tail, span)?; } else if let Some(TypeMember::Slot(slot)) = member { // `Pt.make(1)`, `m.Pt.make(1)`: a method reached // through its type. @@ -1967,7 +1982,8 @@ impl<'a> Compiler<'a> { let argc = args.len(); self.emit_call(argc, tail, span)?; } else { - // Method call on a value: expr.method(args) + // A field's function, or a method on a type held in a + // value (`a.empty()` for a `type a`). self.compile_method_call(callee, receiver, *method, args, span, tail)?; } } else { @@ -1979,8 +1995,48 @@ impl<'a> Compiler<'a> { Ok(()) } - /// Compile `receiver.method(args)`, a call on a value, as the - /// checker's `Selection` on `callee` says. + /// Compile `Tr.method(args)`, a call through a trait, as the + /// checker's `Selection` on `callee` says: the method of one impl, + /// a call of its global; else the method found where the code runs, + /// by the type of the first argument. + fn compile_trait_call( + &mut self, + callee: &Expr, + method: Symbol, + args: &[&Expr], + span: Span, + tail: bool, + ) -> Result<(), Diagnostic> { + use crate::ast::Selection; + match callee.sel { + Some(Selection::Impl { tr, ty }) + if let Some(slot) = self.globals.method(tr, ty, &resolve(method)) => + { + self.emit(Asm::GetGlobal { slot }, span)?; + self.compile_operands(args.iter().copied())?; + self.emit_call(args.len(), tail, span) + } + // Found where the code runs, by the type of the argument of + // type `Self` (a builtin trait's is the first). + Some(Selection::Dynamic { tr, at }) if usize::from(at) < args.len() => { + self.compile_operands(args.iter().copied())?; + self.emit_call_method(method, args.len(), tr, usize::from(at), tail, span) + } + Some(Selection::Impl { tr, .. } | Selection::Native { tr }) if !args.is_empty() => { + self.compile_operands(args.iter().copied())?; + self.emit_call_method(method, args.len(), tr, 0, tail, span) + } + _ => Err(checker_missed( + span, + &format!("the call of '{method}' through its trait with no selection"), + )), + } + } + + /// Compile `receiver.method(args)` as the checker's `Selection` on + /// `callee` says: the function a field holds, or, on a type held in + /// a value (`a.empty()` for a `type a`), the method of the type's + /// impl, found where the code runs. fn compile_method_call( &mut self, callee: &Expr, @@ -2000,27 +2056,18 @@ impl<'a> Compiler<'a> { self.compile_operands(args.iter().copied())?; self.emit_call(args.len(), tail, span) } - // One impl's method: a call of its global, like a function's. - Some(Selection::Impl { tr, ty }) - if let Some(slot) = self.globals.method(tr, ty, &resolve(method)) => - { - self.emit(Asm::GetGlobal { slot }, span)?; - self.compile_operands(with_receiver)?; - self.emit_call(args.len() + 1, tail, span) - } - // The method is found where the code runs, by the receiver's - // type. (An impl with no global is a builtin type's that the - // VM has natively.) - Some( - Selection::Impl { tr, .. } | Selection::Native { tr } | Selection::Dynamic { tr }, - ) => { + // The method is found where the code runs, by the type the + // descriptor carries. + Some(Selection::Dynamic { tr, .. }) => { self.compile_operands(with_receiver)?; - self.emit_call_method(method, args.len() + 1, tr, tail, span) + self.emit_call_method(method, args.len() + 1, tr, 0, tail, span) + } + Some(Selection::Impl { .. } | Selection::Native { .. } | Selection::Field) | None => { + Err(checker_missed( + span, + &format!("the call of '{method}' with no selection"), + )) } - Some(Selection::Field) | None => Err(checker_missed( - span, - &format!("the call of '{method}' with no selection"), - )), } } @@ -2442,13 +2489,14 @@ impl<'a> Compiler<'a> { } /// Emit `CallMethod` of `method` of the trait `t` with `argc` - /// values (the receiver first) on the stack; in tail position - /// (`tail`), `TailCallMethod; Return`. + /// values on the stack, found by the type of the one at `at` (the + /// receiver); in tail position (`tail`), `TailCallMethod; Return`. fn emit_call_method( &mut self, method: Symbol, argc: usize, t: crate::defs::TraitId, + at: usize, tail: bool, span: Span, ) -> Result<(), Diagnostic> { @@ -2466,10 +2514,26 @@ impl<'a> Compiler<'a> { limit_diagnostic(limit, span) })?; if tail { - self.emit(Asm::TailCallMethod { method, argc, of }, span)?; + self.emit( + Asm::TailCallMethod { + method, + argc, + of, + at, + }, + span, + )?; self.emit(Asm::Return, span) } else { - self.emit(Asm::CallMethod { method, argc, of }, span) + self.emit( + Asm::CallMethod { + method, + argc, + of, + at, + }, + span, + ) } } @@ -3722,14 +3786,15 @@ fn main() { list.length([1, 2, 3]) } let fns = compile( r#" type Foo { x: Int } -trait Display for Foo { - fn display(self) -> String { "foo" } +trait Show { fn show(self) -> String } +trait Show for Foo { + fn show(self) -> String { "foo" } } -fn shown(x: a) -> String where a: Display { x.display() } +fn shown(x: a) -> String where a: Show { Show.show(x) } fn field(r: {f: Fn(Int) -> Int}) -> Int { r.f(1) } fn main() { let f = Foo { x: 1 } - f.display() + Show.show(f) } "#, ); diff --git a/src/diagnostic.rs b/src/diagnostic.rs index b87a744d1..496f6f0bb 100644 --- a/src/diagnostic.rs +++ b/src/diagnostic.rs @@ -143,8 +143,8 @@ codes! { NoSuchField = "E0306", Type; MissingField = "E0307", Type; UnknownMethod = "E0308", Type; - /// A method called in a way it cannot be (a method without `self` on - /// a value). + /// A method called in a way it cannot be: through its trait, one + /// that takes no value of the type, or one of `Display` and `Equal`. InvalidMethodCall = "E0309", Type; /// A method several traits provide. AmbiguousMethod = "E0310", Type; diff --git a/src/disassemble.rs b/src/disassemble.rs index a979c95ec..e0c4083ad 100644 --- a/src/disassemble.rs +++ b/src/disassemble.rs @@ -170,13 +170,29 @@ fn disassemble_instruction( } // CallMethod: the id of the method's name, argc, and the name // with the trait whose method it calls (shown after the name - // when the call names one). - Instr::CallMethod { method, argc, of } | Instr::TailCallMethod { method, argc, of } => { + // when the call names one), and the argument it is found by + // where that is not the first. + Instr::CallMethod { + method, + argc, + of, + at, + } + | Instr::TailCallMethod { + method, + argc, + of, + at, + } => { let named = globals.method_name(method).unwrap_or("?"); let line = format!("{offset:04} {name:<20} {method:<5} {argc:<3} ; \"{named}\""); - match globals.trait_name(of) { + let line = match globals.trait_name(of) { Some(t) => format!("{line} of {t}"), None => line, + }; + match at { + 0 => line, + at => format!("{line}, by argument {at}"), } } @@ -543,6 +559,7 @@ mod tests { method, argc: 1, of: 0, + at: 0, }; emitter.emit(call, span()).unwrap(); emitter.emit(Asm::Return, span()).unwrap(); @@ -553,7 +570,7 @@ mod tests { "{output}" ); // The next instruction is decoded after the trait operand. - assert!(output.contains("0006 Return"), "{output}"); + assert!(output.contains("0007 Return"), "{output}"); } #[test] diff --git a/src/lsp/ast_walk.rs b/src/lsp/ast_walk.rs index 9f6871b25..86761e459 100644 --- a/src/lsp/ast_walk.rs +++ b/src/lsp/ast_walk.rs @@ -173,6 +173,45 @@ pub(super) fn find_field_access_at(program: &Program, cursor: usize) -> Option<( found } +/// The method named through its trait whose name holds byte `cursor` +/// (`size` in `Sized.size(b)`), as its trait and its name. +pub(super) fn find_trait_method_at( + program: &Program, + cursor: usize, +) -> Option<(crate::defs::TraitId, Symbol)> { + fn walk(expr: &Expr, cursor: usize, found: &mut Option<(crate::defs::TraitId, Symbol)>) { + if let ExprKind::FieldAccess(receiver, field, field_span) = &expr.kind + && (field_span.start as usize..=field_span.end as usize).contains(&cursor) + && receiver.ty.is_none() + && let Some( + Selection::Impl { tr, .. } + | Selection::Native { tr } + | Selection::Dynamic { tr, .. }, + ) = expr.sel + { + *found = Some((tr, *field)); + } + visit_expr_children(expr, |child| walk(child, cursor, found)); + } + let mut found = None; + for decl in &program.decls { + match decl { + Decl::Fn(f) => walk(&f.body, cursor, &mut found), + Decl::Let { value, .. } => walk(value, cursor, &mut found), + Decl::TraitImpl(ti) => ti + .methods + .iter() + .for_each(|m| walk(&m.body, cursor, &mut found)), + Decl::Trait(t) => t + .methods + .iter() + .for_each(|m| walk(&m.body, cursor, &mut found)), + _ => {} + } + } + found +} + /// Find the identifier name at the cursor byte offset. /// /// Visits `ExprKind::Ident` use-sites AND binding sites: diff --git a/src/lsp/completion.rs b/src/lsp/completion.rs index afc2a8448..e3501f3e2 100644 --- a/src/lsp/completion.rs +++ b/src/lsp/completion.rs @@ -45,6 +45,11 @@ impl Server { if let Some(items) = self.module_member_completions(doc, &prefix, cursor) { return Some(CompletionResponse::Array(items)); } + // A trait's name before the dot: the methods called through + // it. + if let Some(items) = self.trait_method_completions(doc, &prefix, cursor) { + return Some(CompletionResponse::Array(items)); + } // An enum's name before the dot: its variants. if let Some(items) = self.enum_variant_completions(doc, &prefix, cursor) { return Some(CompletionResponse::Array(items)); @@ -217,17 +222,11 @@ impl Server { Some(CompletionResponse::Array(items)) } - /// Produce completions after a `.` — either module functions, record - /// fields, or methods available on the receiver's inferred type. - /// - /// DX-G4: when the LSP can confidently infer the type of - /// the receiver expression (a let-bound local with an annotation, or - /// an identifier whose type was recovered from the typed AST), the - /// emitted method set is narrowed to only those methods registered - /// for that type's canonical head name. When the type cannot be - /// inferred we fall back to the union of all method names declared - /// in the program — preserving discoverability rather than silently - /// hiding completions. + /// Produce completions after a `.`: a builtin module's members, or + /// the fields of the receiver's type when the LSP can infer it (a + /// let-bound local, or an identifier whose type was recovered from + /// the typed AST). A dot after a value is a field: no trait's method + /// is offered there (they are offered after the trait's name). fn dot_completions( &self, checked: Option<&Checked>, @@ -313,9 +312,8 @@ impl Server { }; let program = &*checked.program; - // Resolve the receiver's inferred type once. Used both for the - // record-field path and the method-narrowing path below. Two - // narrow sources are tried: + // The receiver's inferred type, for its fields. Two sources are + // tried: // // (a) a let-bound local in scope at the cursor whose type was // recovered from the value expression (annotation included); @@ -324,16 +322,9 @@ impl Server { // variables. // // Anything else (complex expressions, generics with unresolved - // tyvars, non-identifier prefixes) leaves `receiver_ty = None` - // and the method path falls back to every method the module - // knows — "narrow when safe, never silently lose completions". + // tyvars, non-identifier prefixes) leaves `receiver_ty = None`: + // no fields are offered. let locals = locals_at_offset(program, cursor); - // A builtin module this build lacks (`postgres.` without the - // postgres feature): its import is the error, and it has nothing - // to offer; the methods of every type are not its members. - if module::missing_feature(prefix).is_some() && !locals.iter().any(|l| l.name == prefix) { - return items; - } let receiver_ty: Option = locals .iter() .rev() @@ -342,7 +333,6 @@ impl Server { .or_else(|| find_ident_type_by_name(program, prefix)); // 2. Record fields, if the receiver is a record-shaped type. - let mut emitted_field_labels: HashSet = HashSet::new(); if let Some(ref ty) = receiver_ty && let Some(fields) = record_fields_from_type(ty, &checked.record_fields) { @@ -353,25 +343,7 @@ impl Server { detail: Some(format!("{field_ty}")), ..CompletionItem::default() }); - emitted_field_labels.insert(name.clone()); - } - } - - // 3. Method completions: the methods the checker knows for the - // receiver type's canonical name, or every method it knows - // when the type is unknown. - let methods = methods_for_receiver(&checked.methods, receiver_ty.as_ref()); - for label in methods { - // Don't duplicate a name that already came through as a - // field — fields and methods occupy the same `name.` slot. - if emitted_field_labels.contains(&label) { - continue; } - items.push(CompletionItem { - label, - kind: Some(CompletionItemKind::METHOD), - ..CompletionItem::default() - }); } items.sort_by(|a, b| a.label.cmp(&b.label)); @@ -379,6 +351,41 @@ impl Server { items } + /// The methods of the trait `prefix` names in the open document + /// `doc` that a call through it calls, each with its signature, + /// unless a local binding of that name shadows it. + fn trait_method_completions( + &self, + doc: &Document, + prefix: &str, + cursor: usize, + ) -> Option> { + if doc.program.as_ref().is_some_and(|program| { + locals_at_offset(program, cursor) + .iter() + .any(|local| local.name == prefix) + }) { + return None; + } + let id = self.trait_written(doc, prefix)?; + let mut items: Vec = (self.trait_call_methods(doc, id).into_iter()) + .map(|m| CompletionItem { + label: resolve(m.name), + kind: Some(CompletionItemKind::METHOD), + detail: Some(m.label), + documentation: m.doc.map(|d| { + Documentation::MarkupContent(MarkupContent { + kind: MarkupKind::Markdown, + value: d, + }) + }), + ..CompletionItem::default() + }) + .collect(); + items.sort_by(|a, b| a.label.cmp(&b.label)); + Some(items) + } + /// The variants of the enum `prefix` names in the open document `doc` /// (declared there or imported by name), unless a local binding of /// that name shadows it. @@ -495,7 +502,6 @@ impl Server { let tables = self.checked_tables(doc)?; Some(Checked { program: checked.ast.clone(), - methods: tables.methods(&|module| imports(&checked.ast, module)), record_fields: tables.record_fields(), }) } @@ -538,8 +544,8 @@ impl Server { /// `parse_fn_decl`, which leaves a *recovery stub* for /// the enclosing function — an `FnDecl` with an empty body. Every /// prior `let` in that function disappears from the AST, which means - /// `locals_at_offset` returns nothing for the receiver `xs` and the - /// type-narrowing path can't pin down its type. + /// `locals_at_offset` returns nothing for the receiver `xs` and its + /// fields cannot be offered. /// /// The fix-up gives the project's session, for a moment, a copy of /// the text where the partial dot is followed by a placeholder @@ -599,7 +605,6 @@ impl Server { let tables = project.session.tables(); let checked = project.session.module_analysis(id).map(|checked| Checked { program: checked.ast.clone(), - methods: tables.methods(&|module| imports(&checked.ast, module)), record_fields: tables.record_fields(), }); project.set_text(&path, &original); @@ -638,39 +643,9 @@ fn member_item(view: &ModuleView, member: Symbol, kind: MemberKind) -> Completio /// it. struct Checked { program: Arc, - methods: Vec<(crate::types::TypeRef, Symbol)>, record_fields: RecordFields, } -// ── Method enumeration for dot-completion ────────────────────────── - -/// Whether `program` imports the module `module`. -fn imports(program: &Program, module: &str) -> bool { - program.decls.iter().any(|decl| { - matches!(decl, crate::ast::Decl::Import(target, _) if resolve(target.module()) == module) - }) -} - -/// The names of the methods a value of type `receiver_ty` has, from the -/// checker's `methods` (the type impls key it by, method name): those of -/// the type's head, or every method when the type is unknown. -fn methods_for_receiver( - methods: &[(crate::types::TypeRef, Symbol)], - receiver_ty: Option<&Type>, -) -> Vec { - // Unresolved variables, anonymous records and bottom-typed - // expressions have no dispatch head: they do not narrow. - let head = receiver_ty.and_then(crate::types::canonical::head_of_canon); - let mut names: Vec = methods - .iter() - .filter(|(ty, _)| head.is_none_or(|head| *ty == head)) - .map(|(_, method)| resolve(*method)) - .collect(); - names.sort(); - names.dedup(); - names -} - // ── Dot-completion helpers ───────────────────────────────────────── /// Extract the identifier (or postfix-call / index-expression receiver) @@ -834,65 +809,3 @@ fn extract_dot_prefix(source: &str, pos: &Position) -> Option { // `KEYWORDS` is sourced from `crate::lexer::KEYWORDS` — the authoritative // list maintained alongside the lexer's keyword match arms. Re-introducing // a hand-rolled list here is guarded by `tests/meta/lexer_keyword_parity_tests.rs`. - -#[cfg(test)] -mod tests { - use super::*; - - /// The methods of a user impl and of the builtin derives, as the - /// session's analysis of `source` has them. - fn methods(source: &str) -> Vec<(crate::types::TypeRef, Symbol)> { - let (mut session, file) = crate::session::testing::session_with(&[("main.silt", source)]); - session.analyze(file); - session.tables().methods(&|_| true) - } - - const IMPLS: &str = "trait UpperCaser { fn to_upper(self) -> String }\n\ - trait UpperCaser for String { fn to_upper(self) -> String { \"X\" } }\n\ - trait IntListHead { fn head_int(self) -> Int }\n\ - trait IntListHead for List(a) { fn head_int(self) -> Int { 0 } }\n\ - fn main() { 0 }\n"; - - /// A known receiver type narrows the methods to those of its - /// canonical name, the builtin derived ones included. - #[test] - fn methods_narrow_to_the_receiver_type() { - let methods = methods(IMPLS); - let list = methods_for_receiver(&methods, Some(&Type::List(Box::new(Type::Int)))); - assert!(list.contains(&"head_int".to_string()), "{list:?}"); - assert!(list.contains(&"display".to_string()), "{list:?}"); - assert!(!list.contains(&"to_upper".to_string()), "{list:?}"); - let string = methods_for_receiver(&methods, Some(&Type::String)); - assert!(string.contains(&"to_upper".to_string()), "{string:?}"); - assert!(!string.contains(&"head_int".to_string()), "{string:?}"); - } - - /// A method without `self` is called on the type: it is not offered - /// after a value, of its type or of an unknown one. - #[test] - fn a_method_without_self_is_not_offered_after_a_value() { - let methods = methods( - "trait Mk {\n fn make(n: Int) -> Self\n fn twice(self) -> Self\n}\n\ - trait Mk for Int {\n fn make(n: Int) -> Int { n }\n \ - fn twice(self) -> Int { self * 2 }\n}\nfn main() { 0 }\n", - ); - for receiver in [Some(&Type::Int), None] { - let offered = methods_for_receiver(&methods, receiver); - assert!(offered.contains(&"twice".to_string()), "{offered:?}"); - assert!(!offered.contains(&"make".to_string()), "{offered:?}"); - } - } - - /// An unknown receiver type offers every method the module knows. - #[test] - fn an_unknown_receiver_gets_every_method() { - let methods = methods(IMPLS); - let all = methods_for_receiver(&methods, None); - for name in [ - "to_upper", "head_int", "display", "equal", "compare", "hash", - ] { - assert!(all.contains(&name.to_string()), "{name} missing: {all:?}"); - } - assert_eq!(all, methods_for_receiver(&methods, Some(&Type::Var(0)))); - } -} diff --git a/src/lsp/hover.rs b/src/lsp/hover.rs index a844bf9b2..fa3c6e3c0 100644 --- a/src/lsp/hover.rs +++ b/src/lsp/hover.rs @@ -104,6 +104,19 @@ impl Server { return self.builtin_type_hover_text(doc, ty).map(markdown); } + // A method named through its trait (`size` in `Sized.size(b)`): + // the method as its trait declares it, and its doc comment. + if let Some((tr, method)) = super::ast_walk::find_trait_method_at(program, cursor) + && let Some(m) = + (self.trait_call_methods(doc, tr).into_iter()).find(|m| m.name == method) + { + let mut value = format!("```silt\n{}\n```", m.label); + if let Some(text) = m.doc.filter(|text| !text.is_empty()) { + value.push_str(&format!("\n\n---\n\n{text}")); + } + return Some(markdown(value)); + } + // A trait named (`Display` in `where a: Display`, in an impl's // header, in its own declaration): its signature and its doc. if let Some(tr) = self.trait_named_at(uri, cursor) diff --git a/src/lsp/names.rs b/src/lsp/names.rs index bf5a32f83..df255ea37 100644 --- a/src/lsp/names.rs +++ b/src/lsp/names.rs @@ -55,9 +55,10 @@ impl LocalName { } } -/// A method name at a call or access on a value, `x.scale(2)`: no name -/// of a definition (a method has none of its own), but the checker says -/// which method it is. +/// A method name at a call through its trait, `Sized.scale(x, 2)`, or +/// on a type held in a value, `a.empty()`: no name of a definition (a +/// method has none of its own), but the checker says which method it +/// is. pub(super) struct MethodUse { pub(super) span: Span, pub(super) name: Symbol, @@ -359,9 +360,9 @@ impl<'a> Names<'a> { ExprKind::FieldAccess(receiver, field, field_span) => { // `m.f`, `m.Circle`, `Shape.Circle`: the member's own // name, which the resolver resolved. (The span of a - // field access is its receiver's.) On a value the name - // is a field or a method: no name of a definition, and - // not of the trait the checker selected the method from. + // field access is its receiver's.) After a trait + // (`Sized.size`) the name is the method the checker + // selected; on a value it is a field. let qualified = match receiver.res { Some(Res::Module(_)) => true, Some(Res::Def(id)) => self.table().get(id).is_type(), diff --git a/src/lsp/semantic_tokens.rs b/src/lsp/semantic_tokens.rs index 11143ee3d..472febaf4 100644 --- a/src/lsp/semantic_tokens.rs +++ b/src/lsp/semantic_tokens.rs @@ -294,6 +294,29 @@ fn emit_expr_tokens( emit_expr_tokens(v, source, doc, server, out); } } + // A method named through its trait (`Greet.greet`): the trait + // an INTERFACE, the method a FUNCTION. + ExprKind::FieldAccess(receiver, field, field_span) + if receiver.ty.is_none() + && matches!( + expr.sel, + Some( + crate::ast::Selection::Impl { .. } + | crate::ast::Selection::Native { .. } + | crate::ast::Selection::Dynamic { .. } + ) + ) => + { + match &receiver.kind { + ExprKind::Ident(name) => { + let start = receiver.span.start as usize; + push_token_at_offset(source, start, &resolve(*name), TT_INTERFACE, out); + } + _ => emit_expr_tokens(receiver, source, doc, server, out), + } + let start = field_span.start as usize; + push_token_at_offset(source, start, &resolve(*field), TT_FUNCTION, out); + } ExprKind::Block(stmts) => { for stmt in stmts { emit_stmt_tokens(stmt, source, doc, server, out); diff --git a/src/lsp/signature_help.rs b/src/lsp/signature_help.rs index 9817a2231..0624f4f11 100644 --- a/src/lsp/signature_help.rs +++ b/src/lsp/signature_help.rs @@ -39,6 +39,21 @@ impl Server { let before = tokens.partition_point(|tok| (tok.span.start as usize) < cursor); let (fn_name, active_param) = call_site(&tokens[..before])?; + // `Tr.m(`: the method of the trait, as the trait declares it. + if let Some((tr, method)) = fn_name.rsplit_once('.') + && let Some(id) = self.trait_written(doc, tr) + { + let m = (self.trait_call_methods(doc, id).into_iter()) + .find(|m| resolve(m.name) == method)?; + let params_info = (m.params.iter()) + .map(|range| ParameterInformation { + label: ParameterLabel::LabelOffsets(*range), + documentation: None, + }) + .collect(); + return Some(self.signature(m.label, params_info, m.doc, active_param)); + } + // Look up in definitions first, then builtins. let fn_sym = intern(&fn_name); // A member of an imported module: `m.f(`, or `f(` with `f` from @@ -74,6 +89,19 @@ impl Server { (label, params_info, doc_text) }; + Some(self.signature(label, params_info, doc_text, active_param)) + } + + /// The help of a call of the signature `label`, whose parameters are + /// `params_info`, documented by `doc_text`, at its parameter + /// `active_param`. + fn signature( + &self, + label: String, + params_info: Vec, + doc_text: Option, + active_param: u32, + ) -> SignatureHelp { // A client that does not read label offsets gets each // parameter as its text, a substring of the label. let params_info = if self.label_offsets { @@ -100,7 +128,7 @@ impl Server { }) }); - Some(SignatureHelp { + SignatureHelp { signatures: vec![SignatureInformation { label, documentation, @@ -109,7 +137,7 @@ impl Server { }], active_signature: Some(0), active_parameter: Some(active_param), - }) + } } } @@ -223,12 +251,17 @@ fn call_site(tokens: &[Tok]) -> Option<(String, u32)> { .is_some_and(|tok| tok.kind == Token::Dot) }; let name = name_at(paren.checked_sub(1))?; - // `m.f(`: a member of a module. A longer path (`a.b.f(`) is a method - // or a field of a value, which has no signature here. + // `m.f(`: a member of a module, or `Tr.f(`, a method through its + // trait; `m.Tr.f(`, through a trait of a module. A longer path is a + // field of a value, which has no signature here. if is_dot(paren.checked_sub(2)) { let module = name_at(paren.checked_sub(3))?; if is_dot(paren.checked_sub(4)) { - return None; + let outer = name_at(paren.checked_sub(5))?; + if is_dot(paren.checked_sub(6)) { + return None; + } + return Some((format!("{outer}.{module}.{name}"), *commas)); } return Some((format!("{module}.{name}"), *commas)); } diff --git a/src/lsp/trait_hover.rs b/src/lsp/trait_hover.rs index ba24eeb3c..efaa667ac 100644 --- a/src/lsp/trait_hover.rs +++ b/src/lsp/trait_hover.rs @@ -22,27 +22,20 @@ impl Server { let session = &self.projects.get(&module.project)?.session; let def = session.defs().get(id.0); let (signature, doc_text) = if def.module.is_builtin() || !def.span.is_in_source() { - let (name, module) = crate::defs::builtin_trait_of_id(id.0)?; - match module { + let (decl, q) = self.trait_decl(doc, id)?; + match q { // A trait of the prelude: the checker's declaration. - None => { - let decl = crate::typechecker::builtin_trait_decls() - .into_iter() - .find(|t| resolve(t.name) == name)?; - (signature(&decl, None), decl.doc.clone()) - } + None => (signature(&decl, None), decl.doc.clone()), // A builtin module's (`json.Encode`): the declaration of // the registry, and its section of the module's page. // It is written as a program names it: the trait and the // module's types with the module (`json.Value`). - Some(module) => { - let registry = crate::builtins::registry::registry(); - let of = registry.modules.iter().find(|m| m.name == module)?; - let program = crate::builtins::registry::parse(of.traits); - let decl = declared(&program.decls, |t| resolve(t.name) == name)?; - let section = self.builtin_docs.get(&format!("{module}.{name}")); + Some(q) => { + let section = self + .builtin_docs + .get(&format!("{}.{}", q.module, decl.name)); ( - written(decl, Some(&Qualify::of(of))), + written(&decl, Some(&q)), section.map(|s| below_signature(s)), ) } @@ -62,6 +55,151 @@ impl Server { } } +impl Server { + /// The declaration of the trait `id` in the session of the open + /// document `doc`, with how a builtin module's names are written + /// (`None` for a trait of a file or of the prelude). + fn trait_decl(&self, doc: &Document, id: TraitId) -> Option<(TraitDecl, Option)> { + let module = doc.module.as_ref()?; + let session = &self.projects.get(&module.project)?.session; + let def = session.defs().get(id.0); + if !def.module.is_builtin() && def.span.is_in_source() { + let analysis = session.module_analysis(def.module)?; + let decl = declared(&analysis.ast.decls, |t| t.name_span == def.span)?; + return Some((decl.clone(), None)); + } + let (name, module) = crate::defs::builtin_trait_of_id(id.0)?; + match module { + None => crate::typechecker::builtin_trait_decls() + .into_iter() + .find(|t| resolve(t.name) == name) + .map(|decl| (decl, None)), + Some(module) => { + let registry = crate::builtins::registry::registry(); + let of = registry.modules.iter().find(|m| m.name == module)?; + let program = crate::builtins::registry::parse(of.traits); + let decl = declared(&program.decls, |t| resolve(t.name) == name)?; + Some((decl.clone(), Some(Qualify::of(of)))) + } + } + } + + /// The trait `prefix` names in the open document `doc` (`Greet`, a + /// trait of the prelude, `m.Greet` through an imported module), as + /// the module's analysis binds it. + pub(super) fn trait_written(&self, doc: &Document, prefix: &str) -> Option { + use crate::typechecker::names::Binding; + let scope = &self.checked_module(doc)?.scope; + let module = doc.module.as_ref()?; + let session = &self.projects.get(&module.project)?.session; + let (_, builtin) = crate::typechecker::names::builtins(); + let binding = match prefix.split_once('.') { + None => { + let name = crate::intern::intern(prefix); + (scope.values.get(&name)) + .or_else(|| scope.types.get(&name)) + .or_else(|| builtin.prelude.values.get(&name)) + .or_else(|| builtin.prelude.types.get(&name)) + } + Some((m, t)) => { + let Some(Binding::Module(id)) = scope.values.get(&crate::intern::intern(m)) else { + return None; + }; + let exports = match id.is_builtin() { + true => builtin.modules.get(id), + false => session.module_analysis(*id).map(|a| &a.scope.exports), + }?; + let name = crate::intern::intern(t); + exports + .values + .get(&name) + .or_else(|| exports.types.get(&name)) + } + }; + let Some(Binding::Def(id)) = binding else { + return None; + }; + match session.defs().get(*id).kind { + crate::defs::DefKind::Trait(t) => Some(t), + _ => None, + } + } + + /// The methods of the trait `id` a program calls through it + /// (`Greet.greet(x)`): those that take a value of the type, but + /// `Display`'s and `Equal`'s, each with its signature. + pub(super) fn trait_call_methods(&self, doc: &Document, id: TraitId) -> Vec { + let Some((decl, q)) = self.trait_decl(doc, id) else { + return Vec::new(); + }; + let uncalled = crate::defs::builtin_trait_of_id(id.0) + .is_some_and(|(name, _)| matches!(name, "Display" | "Equal")); + decl.methods + .iter() + .filter(|f| !uncalled && takes_self(f)) + .map(|f| trait_method(q.as_ref(), f)) + .collect() + } +} + +/// A method of a trait as a call through the trait shows it. +pub(super) struct TraitMethod { + pub(super) name: crate::intern::Symbol, + /// `fn greet(self) -> String`. + pub(super) label: String, + /// Where each parameter is in `label`. + pub(super) params: Vec<[u32; 2]>, + pub(super) doc: Option, +} + +/// Whether the method `f` takes a value of the trait's type: a +/// parameter `self`, or one of type `Self`. +fn takes_self(f: &FnDecl) -> bool { + f.params.iter().any(|p| { + matches!(&p.pattern.kind, PatternKind::Ident(name) if resolve(*name) == "self") + || matches!( + &p.ty, + Some(TypeExpr { + kind: TypeExprKind::SelfType, + .. + }) + ) + }) +} + +/// The method `f` as `method` writes it, with where each parameter is. +fn trait_method(q: Option<&Qualify>, f: &FnDecl) -> TraitMethod { + let mut label = format!("fn {}(", f.name); + let mut params = Vec::new(); + for (k, p) in f.params.iter().enumerate() { + if k > 0 { + label.push_str(", "); + } + let name = match &p.pattern.kind { + PatternKind::Ident(name) => resolve(*name), + _ => "_".to_string(), + }; + let text = match &p.ty { + Some(ty) => format!("{name}: {}", type_expr(q, ty)), + None => name, + }; + let start = label.len() as u32; + label.push_str(&text); + params.push([start, label.len() as u32]); + } + label.push(')'); + if let Some(ret) = &f.return_type { + label.push_str(&format!(" -> {}", type_expr(q, ret))); + } + label.push_str(&where_clauses(q, &f.where_clauses)); + TraitMethod { + name: f.name, + label, + params, + doc: f.doc.clone(), + } +} + impl Server { /// What hover shows for silt's own type `id`: its declaration as the /// registry has it (a builtin module's written as a program names diff --git a/src/lsp/workspace.rs b/src/lsp/workspace.rs index 8b1de0e11..257ad7dac 100644 --- a/src/lsp/workspace.rs +++ b/src/lsp/workspace.rs @@ -462,7 +462,7 @@ impl Server { let method = names.methods.iter().find(|m| holds(m.span, cursor))?; let (tr, ty) = match method.selection { Selection::Impl { tr, ty } => (tr, Some(ty)), - Selection::Native { tr } | Selection::Dynamic { tr } => (tr, None), + Selection::Native { tr } | Selection::Dynamic { tr, .. } => (tr, None), Selection::Field | Selection::FieldCall => return None, }; let named = |methods: &[FnDecl]| { diff --git a/src/repl.rs b/src/repl.rs index 998af7a47..4508e760c 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -727,7 +727,7 @@ mod tests { ); } // The session is what it was. - assert_eq!(value(&mut repl, "U(1).m()"), "a"); + assert_eq!(value(&mut repl, "A.m(U(1))"), "a"); assert_eq!(value(&mut repl, "f(U(2))"), "U(2)"); } diff --git a/src/session/mod.rs b/src/session/mod.rs index 0a3692657..b9e857347 100644 --- a/src/session/mod.rs +++ b/src/session/mod.rs @@ -625,44 +625,15 @@ impl Session { for d in &ordering.cycles { push(d, &mut out); } - // An unknown method that a trait of a module not imported has: - // the help that names the module, now that all are checked. - let helped = |id: ModuleId, d: &Diagnostic| { - let mut d = d.clone(); - if !self.cells.info.contains_key(&id) { - // (Only an error that says a type has no such method: - // another error may stand at the same place.) - let about_a_method = matches!( - d.code, - Code::UnknownMethod | Code::UnknownField | Code::UnresolvedName - ); - if about_a_method && d.is_error() { - let reach = self.graph.reach(id); - let imports_back = |owner| self.graph.reach(owner).contains(&id); - for (span, help) in typechecker::out_of_reach_helps( - &self.tables, - &self.defs, - id, - &reach, - imports_back, - ) { - if span == d.span && !d.help.contains(&help) { - d.help.push(help); - } - } - } - } - d - }; if let Some(analysis) = self.analyses.get(&entry) { for d in &analysis.diagnostics { - push(&helped(entry, d), &mut out); + push(d, &mut out); } } for &id in ordering.modules.iter().filter(|&&id| id != entry) { if let Some(analysis) = self.analyses.get(&id) { for d in analysis.diagnostics.iter().filter(|d| d.is_error()) { - push(&helped(id, d), &mut out); + push(d, &mut out); } } } diff --git a/src/typechecker/builtin_env.rs b/src/typechecker/builtin_env.rs index a8436b2af..06552230d 100644 --- a/src/typechecker/builtin_env.rs +++ b/src/typechecker/builtin_env.rs @@ -342,7 +342,6 @@ fn enter_registry(checker: &mut TypeChecker, env: &mut TypeEnv) { method_type: Type::Fun(vec![self_ty.clone()], Box::new(Type::String)), structural: false, trait_name: Some(key), - receiver: true, preds: Vec::new(), }, ); @@ -412,38 +411,25 @@ fn argument_checks(row: &crate::builtins::registry::Row, ty: &Type) -> Vec /// registrations of the builtin init, for the policy locks /// in `tests/cli/trait_init_parity_tests.rs`. /// -/// Returns `(trait_impls, method_keys)` where: -/// - `trait_impls` is the set of `"Trait:Type"` pairs registered in -/// `trait_impl_set`. -/// - `method_keys` is the set of `"Type.method"` pairs the builtins -/// have (`Tables::methods`). +/// Returns the set of `"Trait:Type"` pairs registered in +/// `trait_impl_set`. /// /// Stringifies the `Symbol` keys so test code doesn't need access to /// the crate-private `Symbol`/`intern` types. #[doc(hidden)] -pub fn __trait_init_fingerprint_check_program() -> ( - std::collections::BTreeSet, - std::collections::BTreeSet, -) { +pub fn __trait_init_fingerprint_check_program() -> std::collections::BTreeSet { use std::collections::BTreeSet; let mut checker = TypeChecker::new(); let mut env = TypeEnv::new(); register_prelude(&mut checker, &mut env); enter_registry(&mut checker, &mut env); register_builtin_trait_impls(&mut checker); - let trait_impls: BTreeSet = checker + checker .tables .trait_impl_set .iter() .map(|(tr, ty)| format!("{}:{}", resolve(tr.name), resolve(ty.name))) - .collect(); - let method_keys: BTreeSet = checker - .tables - .methods(&|_| true) - .iter() - .map(|(ty, m)| format!("{}.{}", resolve(ty.name), resolve(*m))) - .collect(); - (trait_impls, method_keys) + .collect::>() } /// Test-only introspection for the built-in trait declarations diff --git a/src/typechecker/builtin_traits.rs b/src/typechecker/builtin_traits.rs index 622c1e417..ede8540e8 100644 --- a/src/typechecker/builtin_traits.rs +++ b/src/typechecker/builtin_traits.rs @@ -111,8 +111,8 @@ pub fn builtin_trait_decls() -> Vec { is_pub: true, span: dummy_span, doc: Some( - "How a value is shown: `println`, `print`, interpolation, `.display()`\n\ - and `string.from` show it so. A type has it by its structure, or by an\n\ + "How a value is shown: `println`, `print`, interpolation and\n\ + `string.from` show it so. A type has it by its structure, or by an\n\ impl written in the module that declares the type." .to_string(), ), @@ -213,7 +213,7 @@ pub fn builtin_trait_decls() -> Vec { .to_string(), ), }, - // trait Error: Display { fn message(self) -> String { self.display() } } + // trait Error: Display { fn message(self) -> String { "{self}" } } TraitDecl { name: intern("Error"), name_span: dummy_span, diff --git a/src/typechecker/declare_traits.rs b/src/typechecker/declare_traits.rs index 4fb16f0ee..e8f065bda 100644 --- a/src/typechecker/declare_traits.rs +++ b/src/typechecker/declare_traits.rs @@ -175,7 +175,6 @@ impl TypeChecker { method_type: substitute_vars(method_ty, &mapping), structural: false, trait_name: Some(*trait_name), - receiver: trait_info.receivers.contains(method_name), preds, }, ); @@ -657,13 +656,13 @@ impl TypeChecker { /// another module. Why, for the impl of trait `T` for type `Y`, /// written in module `I` (`T`'s or `Y`'s): /// - /// - A call that names the impl where it is written (`y.m()` with - /// `y: Y`, `Y.m`), in a module `X`: `X` has `T` and `Y` in its + /// - A call that names the impl where it is written (`T.m(y)` with + /// `y: Y`), in a module `X`: `X` has `T` and `Y` in its /// types. A type comes into a module's types only through what /// the module imports, and a method of `T` is selected only where /// `T`'s module is imported, directly or through imports /// (`method_entry`). So `X` imports `I`, or is `I`. - /// - A call decided where the code runs (`x.m()` with `x: a where + /// - A call decided where the code runs (`T.m(x)` with `x: a where /// a: T`, a default method, the formatter for `Display`), in a /// module that need not import `Y`'s module. If `I` is `T`'s /// module, the calling code names `T`, so its module imports `I`, @@ -1808,7 +1807,6 @@ impl TypeChecker { method_type: fn_type, structural: false, trait_name: Some(trait_key), - receiver: declared_receiver.unwrap_or_else(|| writes_self(method)), preds: (method_constraints.iter().cloned()) .chain(self.given_to(&method_rigid, trait_key, target_type, method.name)) .collect(), @@ -1897,7 +1895,6 @@ impl TypeChecker { method_type: substitute_vars(ty, &mapping), structural: false, trait_name: Some(trait_key), - receiver: info.receivers.contains(name), preds: method_constraints, }, ); diff --git a/src/typechecker/inference.rs b/src/typechecker/inference.rs index da3642729..6ee83b8fb 100644 --- a/src/typechecker/inference.rs +++ b/src/typechecker/inference.rs @@ -49,11 +49,18 @@ enum CallForm { /// The call to write for a method without `self` where only a type /// variable is at hand: on a `type` parameter of that variable. -pub(super) fn on_type_parameter(var: Symbol, method: Symbol, method_ty: &Type) -> String { - format!( - "{}, where `{var}` is a `type {var}` parameter", - on_type_call(&resolve(var), method, method_ty) - ) +/// How a program does what the method `method` of the builtin trait +/// `tr` would, where that method is not called (`display`, `equal`): +/// the help of an error at a call of it. `None` for any other method. +pub(super) fn uncallable_builtin(tr: TraitKey, method: Symbol, x: &str) -> Option { + let builtin = crate::defs::builtin_trait_id(&resolve(tr.name)) == Some(tr.id); + match (builtin, resolve(tr.name).as_str(), resolve(method).as_str()) { + (true, "Display", "display") => Some(format!( + "show a value with interpolation, `\"{{{x}}}\"`, or with `string.from({x})`" + )), + (true, "Equal", "equal") => Some(format!("compare with `==`: `{x} == y`")), + _ => None, + } } /// The call of the method `method`, of the type `method_ty`, on the type @@ -156,37 +163,7 @@ pub(super) fn format_record_field_suggestion( (base, help) } -/// The "unknown method '' on " message, with a "did you -/// mean ``?" help when one of `methods`, the names of the type's -/// methods, is close to `field` (`suggest::suggest_similar`). -pub(super) fn format_unknown_method_message( - field: Symbol, - display_type_name: &str, - methods: &[Symbol], -) -> (String, Option) { - let field_str = resolve(field); - let base = format!("unknown method '{field_str}' on {display_type_name}"); - let candidates: Vec = methods.iter().map(|m| resolve(*m).to_string()).collect(); - let help = suggest_similar(&field_str, candidates.iter()) - .map(|hint| format!("did you mean `{hint}`?")); - (base, help) -} - impl TypeChecker { - /// The "unknown method" message for `field` of the type `ty`, with - /// a method of a similar name as its help. That it was reported is - /// kept (`note_unknown_method`). - fn unknown_method_message( - &mut self, - field: Symbol, - display: &str, - ty: TypeRef, - span: Span, - ) -> (String, Option) { - self.note_unknown_method(span, ty, field); - format_unknown_method_message(field, display, &self.method_names(ty)) - } - /// Put `var: trait_name` (at the trait arguments `args`) in scope, /// and with it each supertrait, at the arguments the trait's /// declaration gives it: `where a: Ordered` with @@ -239,50 +216,29 @@ impl TypeChecker { &mut self, recv: &Type, method: Symbol, - on_type: bool, span: Span, ) -> Option { - let (tr, others, result) = match resolve(method).as_str() { - // (Called through the type only: it takes no `self`.) - "decode" if !on_type => return None, - "compare" => ("Compare", 1, Some(Type::Int)), - "equal" => ("Equal", 1, Some(Type::Bool)), - "hash" => ("Hash", 0, Some(Type::Int)), - "display" => ("Display", 0, Some(Type::String)), - "encode" => ( - "Encode", - 0, - Some(Type::Generic(TypeRef::builtin("Value"), vec![])), - ), - "decode" => ("Decode", 0, None), - _ => return None, - }; - let tr = TraitKey::builtin(tr); + // (The structural methods that take a value of the type are + // called through their traits; through the type, `decode`.) + if resolve(method) != "decode" { + return None; + } + let tr = TraitKey::builtin("Decode"); let head = self.type_name_for_impl(&self.apply(recv))?; // (A trait of a builtin module, where the module checked does - // not import it, gives no method: `.encode()` needs `import + // not import it, gives no method: `T.decode` needs `import // json`.) if !self.by_structure(tr, head) || self.unreached(tr).is_some() { return None; } - let ty = match result { - Some(result) => { - let mut params = vec![recv.clone()]; - params.extend(std::iter::repeat_n(recv.clone(), others)); - Type::Fun(params, Box::new(result)) - } - None => { - let info = self.tables.traits.get(&tr)?; - let (_, declared) = info.methods.iter().find(|(name, _)| *name == method)?; - let mapping = HashMap::from([(info.self_var, recv.clone())]); - substitute_vars(declared, &mapping) - } + let ty = { + let info = self.tables.traits.get(&tr)?; + let (_, declared) = info.methods.iter().find(|(name, _)| *name == method)?; + let mapping = HashMap::from([(info.self_var, recv.clone())]); + substitute_vars(declared, &mapping) }; // (A refusal of `T.decode` names it so.) - let callee = match tr.is_builtin("Decode") { - true => intern(&format!("{head}.{method}")), - false => method, - }; + let callee = intern(&format!("{head}.{method}")); self.want( Pred::Trait { tr, @@ -296,7 +252,6 @@ impl TypeChecker { op: None, }, ); - self.last_field_access_was_method = true; self.method_trait = Some(tr); Some(ty) } @@ -602,236 +557,17 @@ impl TypeChecker { (owner != self.module).then_some(module) } - /// The private trait of another module that alone provides `method`: - /// every impl that has a method of that name is of such a trait, and - /// no trait this module may name declares it. - fn only_private_provider(&self, method: Symbol) -> Option { - // (A structural trait's method is every type's.) - let name = resolve(method); - if STRUCTURAL_METHODS.iter().any(|(_, m)| *m == name) { - return None; - } - let mut providers = self - .tables - .impl_methods - .keys() - .filter(|(_, m, _)| *m == method) - .map(|(_, _, tr)| *tr); - let first = providers.next()?; - if self.private_owner(first).is_none() || providers.any(|t| self.private_owner(t).is_none()) - { - return None; - } - let visible_declares = self.tables.traits.iter().any(|(key, info)| { - self.private_owner(*key).is_none() && info.methods.iter().any(|(n, _)| *n == method) - }); - (!visible_declares).then_some(first) - } - - /// The method `field` of a value whose type is the annotation - /// variable `r`, with the trait that declares it; `None` when there - /// is none, which is reported. An annotation variable has the - /// methods of its bounds, and nothing else: no field, no method of a - /// trait the declaration does not promise. This is the one answer, - /// whether the receiver was known where the call is written or - /// became known later. - pub(super) fn bound_method( - &mut self, - r: RigidId, - field: Symbol, - span: Span, - ) -> Option<(TraitKey, Type)> { - let matches = self.bound_methods(r, field); - let matches = self.on_a_value(matches, |(t, _)| *t, field); - if matches.len() > 1 { - let traits: Vec = matches.iter().map(|(t, _)| *t).collect(); - self.ambiguous_bound_method( - field, - &format!("a value of type `{}`", r.name), - r, - &traits, - span, - ); - return None; - } - if let Some((trait_name, scheme)) = matches.first() { - let receiver = self - .tables - .traits - .get(trait_name) - .is_none_or(|info| info.receivers.contains(&field)); - let method_ty = self.instantiate_method(scheme, field, span); - let on_type = on_type_parameter(r.name, field, &method_ty); - return match self.takes_no_self(receiver, field, &on_type, span) { - true => None, - false => Some((*trait_name, method_ty)), - }; - } - // One of its bounds names an unknown trait (reported): the - // method may be that trait's. - if self.unknown_bounds.contains(&r.var) { - return None; - } - let mut bounds: Vec = self - .bounds - .get(&r.var) - .map(|bounds| bounds.iter().map(|(t, _)| *t).collect()) - .unwrap_or_default(); - distinct(&mut bounds); - if bounds.is_empty() { - self.errors.push( - Diagnostic::error( - Code::UnknownMethod, - span, - format!( - "no field or method '{field}' on a value of type `{}`: \ - the type variable has no trait bound", - r.name - ), - ) - .with_help(format!( - "a value of type `{0}` has only the methods its bounds \ - promise: add `where {0}: SomeTrait`", - r.name - )), - ); - } else { - let bounds = bounds - .iter() - .map(|s| format!("{s}")) - .collect::>() - .join(" + "); - self.error( - Code::UnknownMethod, - format!("no method '{field}' found in trait constraints ({bounds})"), - span, - ); - } - None - } - - /// `value.method` where the method has no `self` (`receiver`, the - /// fact its trait declares: `TraitInfo::receivers`): reported, with - /// `on_type` as the call to write instead (`` `Int.empty()` ``). A - /// method without `self` is called on a type, never on a value: none - /// of its parameters is for the receiver. - pub(super) fn takes_no_self( - &mut self, - receiver: bool, - method_name: Symbol, - on_type: &str, - span: Span, - ) -> bool { - let no_self = !receiver; - if no_self { - self.error( - Code::InvalidMethodCall, - format!( - "method `{method_name}` takes no `self` — \ - call it on the type instead: {on_type}" - ), - span, - ); - } - no_self - } - - /// The type of `receiver.method` for the impl method `entry`: the - /// method's scheme instantiated (`instantiate`), with the receiver - /// unified with its `self` parameter, so that what the impl's header - /// and the method ask of the receiver's parts is checked against the - /// receiver's type; on a part still unknown it waits like any - /// predicate owed. - pub(super) fn dispatch_method_entry( - &mut self, - entry: &MethodEntry, - method_name: Symbol, - receiver_ty: &Type, - span: Span, - ) -> Type { - self.last_field_access_was_method = true; - let head = self.type_name_for_impl(&self.apply(receiver_ty)); - // A method of a trait another module declares without `pub` can - // be called only in that module. - if let Some(trait_name) = entry.trait_name - && self.private_owner(trait_name).is_some() - { - self.private_method(trait_name, method_name, span); - return Type::Error; - } - if let Some(head) = head - && self.ambiguous_method_call(head, method_name, false, span) - { - return Type::Error; - } - // A method of a structural trait: the type has it when it has - // the trait by its structure, which the call owes. The entry - // only says that the name is the trait's. - if entry.structural - && let Some(method_ty) = self.structural_method(receiver_ty, method_name, false, span) - { - return method_ty; - } - self.method_trait = self.entry_trait(entry, method_name); - // What the impl and the method ask of the receiver's parts and - // of the method's own type variables is owed, and checked once - // the receiver is unified with the method's `self` below. - let owed_before = self.wanted.len(); - let scheme = self.method_scheme(entry); - let instantiated_ty = self.instantiate_method(&scheme, method_name, span); - // A method without `self` has no place for the receiver. - let on = self - .type_name_for_impl(&self.apply(receiver_ty)) - .map_or_else(|| "SomeType".to_string(), |ty| ty.to_string()); - let on_type = on_type_call(&on, method_name, &instantiated_ty); - if self.takes_no_self(entry.receiver, method_name, &on_type, span) { - return Type::Error; - } - // Unify the receiver with the method's self param so concrete - // receiver element types flow into the impl's tyvars before the - // constraint check below. - if let Type::Fun(params, _) = &instantiated_ty - && let Some(self_param) = params.first() - { - self.unify(receiver_ty, self_param, span); - } - // A method of a structural trait (`.compare()`, `.equal()`, - // `.hash()`, a derived `.display()`) is the receiver's when its - // parts have the trait too. - if let Some(tr) = self.entry_trait(entry, method_name) - && let Some(head) = head - && crate::defs::builtin_trait_id(&resolve(tr.name)) == Some(tr.id) - && self.by_structure(tr, head) - { - self.want( - Pred::Trait { - tr, - args: Vec::new(), - subject: receiver_ty.clone(), - asker: None, - }, - Origin { - span, - callee: Some(method_name), - op: None, - }, - ); - } - self.solve_wanted(owed_before); - self.apply(&instantiated_ty) - } - - /// Resolve a method on a type descriptor (`TypeOf(inner)`). The - /// descriptor is a type carrier — lookup uses `inner`'s effective type - /// name (for concrete inners) or the active trait constraints (for a - /// type variable inner). Returns the method's function type with all - /// `Self` references substituted to `inner`. + /// Resolve a method that makes a value on a type descriptor + /// (`TypeOf(inner)`, `a.empty()`). The descriptor is a type carrier — + /// lookup uses `inner`'s effective type name (for concrete inners) or + /// the active trait constraints (for a type variable inner). Returns + /// the method's function type with all `Self` references substituted + /// to `inner`; a method that takes a value of the type is reported + /// (it is called through its trait). /// - /// Unlike value-receiver dispatch, the descriptor does NOT occupy an - /// argument slot of the method. Callers signal this by leaving - /// `last_field_access_was_method = false` after this returns, so the - /// downstream Call arm unifies args with params[0..] rather than - /// params[1..]. + /// The descriptor occupies no parameter of the method: + /// `receiver_taken` stays false, so the call unifies its arguments + /// with all of the method's parameters. pub(super) fn resolve_type_descriptor_method( &mut self, inner: &Type, @@ -902,6 +638,10 @@ impl TypeChecker { ); return None; } + if self.self_param(matches[0].0, field).is_some() { + self.through_its_trait(&inner.to_string(), matches[0].0, field, span); + return Some(Type::Error); + } self.method_trait = Some(matches[0].0); let instantiated = self.instantiate_method(&matches[0].1, field, span); Some(self.apply(&instantiated)) @@ -911,14 +651,21 @@ impl TypeChecker { // the effective type name (same path as // `type_name_for_impl`). let name = self.type_name_for_impl(&inner)?; - let entry = self.method_entry(name, field, true)?; + let entry = self.method_entry(name, field)?; + if let Some(tr) = self.entry_trait(&entry, field) + && self.self_param(tr, field).is_some() + { + let shown = self.show_type(&inner); + self.through_its_trait(&shown, tr, field, span); + return Some(Type::Error); + } if let Some(trait_name) = entry.trait_name && self.private_owner(trait_name).is_some() { self.private_method(trait_name, field, span); return Some(Type::Error); } - if self.ambiguous_method_call(name, field, true, span) { + if self.ambiguous_method_call(name, field, span) { return Some(Type::Error); } if self.of_every_shape(name, &entry, field, span) { @@ -935,11 +682,317 @@ impl TypeChecker { } } - /// `T.method` where the method is one of a builtin structural trait - /// that the type `ty`, of the instance `inner`, has by its structure - /// (`Int.display`, `P.compare`): the method `structural_method` - /// gives a value of `inner`. Written through the type, every - /// parameter is an argument of the call, the receiver too. + /// The trait an expression names (`Greet`, `m.Greet`, `Compare`), as + /// the resolver resolved it; `None` for anything else. + pub(super) fn trait_named(&self, expr: &Expr) -> Option { + if !matches!(expr.kind, ExprKind::Ident(_) | ExprKind::FieldAccess(..)) { + return None; + } + match expr.res { + Some(crate::defs::Res::Def(id)) => self.trait_key(id), + _ => None, + } + } + + /// The type of `Tr.field`, a method of the trait `tr` called through + /// it: the method's type with a type of its own for `Self`, whose + /// impl the call reaches (the type of the arguments it is given). + /// The use owes `Self: Tr`, the method's own bounds, and what the + /// method of that impl asks (`Pred::Via`), as a call on a value of + /// that type would. A method that takes no value of type `Self` + /// cannot say which impl it is of: it is called on a type. + fn trait_method( + &mut self, + tr: TraitKey, + field: Symbol, + receiver: Option<(Type, Span)>, + span: Span, + ) -> Type { + let Some(info) = self.tables.traits.get(&tr).cloned() else { + return Type::Error; + }; + let Some((_, method_ty)) = info.methods.iter().find(|(n, _)| *n == field) else { + let message = format!("trait '{}' has no method '{field}'", self.show_trait(tr)); + let names: Vec = info.methods.iter().map(|(n, _)| resolve(*n)).collect(); + let help = super::suggest::suggest_similar(&resolve(field), &names) + .map(|name| format!("did you mean '{name}'?")); + self.error_help(Code::UnknownMethod, (message, help), span); + return Type::Error; + }; + if let Some(how) = uncallable_builtin(tr, field, "x") { + self.error_help( + Code::InvalidMethodCall, + ( + format!("trait '{}' has no callable methods", self.show_trait(tr)), + Some(how), + ), + span, + ); + return Type::Error; + } + if self.private_owner(tr).is_some() { + self.private_method(tr, field, span); + return Type::Error; + } + let takes_self = matches!(method_ty, Type::Fun(params, _) + if params.iter().any(|p| matches!(p, Type::Var(v) if *v == info.self_var))); + if !takes_self { + self.errors.push( + Diagnostic::error( + Code::InvalidMethodCall, + span, + format!( + "method '{field}' of trait '{}' takes no value of the type, so it is \ + called on a type", + self.show_trait(tr) + ), + ) + .with_help(format!( + "call it on a type, {}, or on a `type a` parameter, {}", + on_type_call("T", field, method_ty), + on_type_call("a", field, method_ty) + )), + ); + return Type::Error; + } + // Called with its first argument a value of a type that has an + // impl written: the method of that impl, as a function of the + // impl's module calls it, owing what the impl's header and the + // method's body ask (`dispatch_method_entry`). + if let Some((recv, _)) = &receiver { + let recv = self.apply(recv); + let entry = match crate::types::canonical::canonicalize(&self.tables.resolver, &recv) { + Type::Var(_) | Type::Rigid(_) | Type::Error | Type::Never => None, + canon => (self.type_name_for_impl(&canon)) + .and_then(|head| self.tables.impl_methods.get(head, field, tr)) + .filter(|entry| !entry.structural) + .cloned(), + }; + if let Some(entry) = entry { + self.method_trait = Some(tr); + self.trait_call_self.insert(span, recv.clone()); + self.receiver_taken = true; + let owed_before = self.wanted.len(); + let scheme = self.method_scheme(&entry); + let ty = self.instantiate_method(&scheme, field, span); + if let Type::Fun(params, _) = &ty + && let Some(first) = params.first() + { + self.unify(&recv, first, span); + } + self.solve_wanted(owed_before); + return self.apply(&ty); + } + } + let self_ty = self.fresh_var(); + let mut mapping: HashMap = HashMap::new(); + mapping.insert(info.self_var, self_ty.clone()); + let params: Vec = info + .param_var_ids + .iter() + .map(|v| { + let fresh = self.fresh_var(); + mapping.insert(*v, fresh.clone()); + fresh + }) + .collect(); + let ty = substitute_vars(method_ty, &mapping); + let preds: Vec = info + .method_bounds + .get(&field) + .into_iter() + .flatten() + .map(|pred| pred.substitute(&mapping)) + .chain([Pred::Via { + tr, + method: field, + receiver: self_ty.clone(), + method_ty: ty.clone(), + passer: None, + at: None, + }]) + .collect(); + let own: Vec = free_vars_in(method_ty) + .into_iter() + .filter(|v| !mapping.contains_key(v)) + .collect(); + let scheme = Scheme { + vars: own, + preds, + ty, + }; + if let Some((recv, _)) = &receiver { + self.unify(recv, &self_ty, span); + } + self.want( + Pred::Trait { + tr, + args: params, + subject: self_ty.clone(), + asker: None, + }, + Origin { + span: receiver.as_ref().map_or(span, |(_, at)| *at), + callee: Some(field), + op: None, + }, + ); + self.method_trait = Some(tr); + self.trait_call_self.insert(span, self_ty); + self.receiver_taken = receiver.is_some(); + let method_ty = self.instantiate_method(&scheme, field, span); + self.apply(&method_ty) + } + + /// Report `recv.field` where a value of the type `ty` has no field + /// `field` (`fields`: the fields it has): when a trait in sight has a + /// method of that name, or a builtin module of the type a function, + /// the help says how to call it; else a field of a similar name. + pub(super) fn no_field( + &mut self, + ty: &Type, + field: Symbol, + recv: Option<&Expr>, + fields: &[(Symbol, Type)], + span: Span, + ) { + let shown = self.show_type(ty); + let base = format!("type '{shown}' has no field '{field}'"); + let placeholder = match ty { + Type::List(_) => "xs", + _ => "x", + }; + let written = match recv.map(|recv| &recv.kind) { + Some(ExprKind::Ident(name)) => resolve(*name), + _ => placeholder.to_string(), + }; + let help = match self.method_help(ty, field, &written) { + Some(help) => Some(help), + None => format_record_field_suggestion(base.clone(), field, fields).1, + }; + self.error_help(Code::UnknownField, (base, help), span); + } + + /// How to call the method or function `field` that a dot after a + /// value of the type `ty`, written `written`, names, if a trait in + /// sight or a builtin module of the type has one of that name: the + /// help of `no_field`. + pub(super) fn method_help(&self, ty: &Type, field: Symbol, written: &str) -> Option { + let mut traits: Vec = (self.tables.traits.iter()) + .filter(|(_, info)| info.methods.iter().any(|(n, _)| *n == field)) + .map(|(t, _)| *t) + .filter(|t| self.sees_trait(*t) && self.private_owner(*t).is_none()) + .collect(); + traits.sort_by_key(|t| self.show_trait(*t)); + if let Some(tr) = traits.first().copied() { + if let Some(how) = uncallable_builtin(tr, field, written) { + return Some(how); + } + let shown = self.show_trait(tr); + let params = self.method_arity(tr, field); + return Some(match self.self_param(tr, field) { + Some(_) => { + let rest = if params > 1 { ", .." } else { "" }; + format!( + "`{field}` is a method of trait `{shown}`: call it as \ + `{shown}.{field}({written}{rest})`" + ) + } + None => { + // (A type variable is called on as the `type a` + // parameter that would name it.) + let (on, parameter) = match ty { + Type::Rigid(r) => ( + r.name.to_string(), + format!(", where `{0}` is a `type {0}` parameter", r.name), + ), + _ => ( + self.type_name_for_impl(ty) + .map_or_else(|| "T".to_string(), |t| t.name.to_string()), + String::new(), + ), + }; + let args = if params > 0 { ".." } else { "" }; + format!( + "`{field}` is a method of trait `{shown}` that makes a value: call it \ + on the type, `{on}.{field}({args})`{parameter}" + ) + } + }); + } + let module = match ty { + Type::List(_) => "list", + Type::String => "string", + Type::Map(..) => "map", + Type::Set(_) => "set", + Type::Int => "int", + Type::Float => "float", + Type::Channel(_) => "channel", + Type::Generic(name, _) if name.is_builtin("Option") => "option", + Type::Generic(name, _) if name.is_builtin("Result") => "result", + Type::Generic(name, _) if name.is_builtin("Bytes") => "bytes", + _ => return None, + }; + crate::builtins::registry::registry() + .row(module, &resolve(field)) + .filter(|row| row.enabled) + .map(|_| { + format!( + "`{field}` is a function of module `{module}`: call it as \ + `{module}.{field}({written})`" + ) + }) + } + + /// Report `T.field`, through the type `on`, of the method `field` of + /// the trait `tr`, which takes a value of the type: it is called + /// through its trait. + fn through_its_trait(&mut self, on: &str, tr: TraitKey, field: Symbol, span: Span) { + let shown = self.show_trait(tr); + let more = self.self_param(tr, field).is_some() && self.method_arity(tr, field) > 1; + let rest = if more { ", .." } else { "" }; + let help = match uncallable_builtin(tr, field, "x") { + Some(how) => how, + None => format!( + "`{field}` is a method of trait `{shown}`: call it as `{shown}.{field}(x{rest})`" + ), + }; + self.error_help( + Code::UnknownMethod, + (format!("type '{on}' has no method '{field}'"), Some(help)), + span, + ); + } + + /// The number of parameters of the method `field` of the trait `tr`. + fn method_arity(&self, tr: TraitKey, field: Symbol) -> usize { + (self.tables.traits.get(&tr)) + .and_then(|info| info.methods.iter().find(|(n, _)| *n == field)) + .and_then(|(_, ty)| match ty { + Type::Fun(params, _) => Some(params.len()), + _ => None, + }) + .unwrap_or(0) + } + + /// The index of the first parameter of type `Self` of the method + /// `field` of the trait `tr`: the argument a call through the trait + /// picks the impl by. `None` when the method has none, or the trait + /// no such method. + pub(super) fn self_param(&self, tr: TraitKey, field: Symbol) -> Option { + let info = self.tables.traits.get(&tr)?; + let (_, ty) = info.methods.iter().find(|(n, _)| *n == field)?; + match ty { + Type::Fun(params, _) => params + .iter() + .position(|p| matches!(p, Type::Var(v) if *v == info.self_var)), + _ => None, + } + } + + /// `T.decode` where the type `ty`, of the instance `inner`, has + /// `json.Decode` by its structure: the method `structural_method` + /// gives `inner`. fn structural_type_method( &mut self, ty: TypeRef, @@ -947,8 +1000,7 @@ impl TypeChecker { field: Symbol, span: Span, ) -> Type { - let method = self.structural_method(inner, field, true, span); - self.last_field_access_was_method = false; + let method = self.structural_method(inner, field, span); match method { Some(method) => self.apply(&method), // The type has the method by its structure, so the @@ -1037,9 +1089,6 @@ impl TypeChecker { format!("type '{shown}' has no method '{field}'"), ); let qualified = intern(&format!("{module}.{field}")); - if let Some(ty) = ty { - self.note_unknown_method(span, ty, field); - } if crate::module::is_builtin_module(&module) && builtin_env_has(qualified) { d = d.with_help(format!( "did you mean `{module}.{field}`, a function of module `{module}`?" @@ -1597,7 +1646,7 @@ impl TypeChecker { // Reset the method-dispatch flag so a stale value from an // earlier field access does not leak into this call, and read it // before the arguments are checked (they may overwrite it). - self.last_field_access_was_method = false; + self.receiver_taken = false; self.named_use = Self::callee_label(callee).map(|label| Origin { span, callee: Some(label), @@ -1605,13 +1654,29 @@ impl TypeChecker { }); self.callee_position = true; self.unknown_receiver = None; + // `Tr.m(x, ..)`: the argument of type `Self` is checked with the + // callee, as a receiver: the impl is the one for its type. + let through_trait = match &callee.kind { + ExprKind::FieldAccess(obj, field, _) if !args.is_empty() => self + .trait_named(obj) + .is_some_and(|tr| self.self_param(tr, *field) == Some(0)), + _ => false, + }; + if through_trait { + let receiver = args.remove(0); + self.callee_position = false; + let recv_ty = self.infer_expr(receiver, env); + self.callee_position = true; + self.trait_receiver = Some((recv_ty, receiver.span)); + } let callee_ty = self.infer_expr(callee, env); + self.trait_receiver = None; self.callee_position = false; self.named_use = None; let callee_ty = self.apply(&callee_ty); - let is_method_call = self.last_field_access_was_method; - self.last_field_access_was_method = false; - // `x.m(args)` where the type of `x` is unknown: the call waits + let receiver_taken_by_callee = self.receiver_taken; + self.receiver_taken = false; + // `x.f(args)` where the type of `x` is unknown: the call waits // for it. if let Some((recv, name)) = self.unknown_receiver.take() { let args: Vec = args.iter_mut().map(|a| self.infer_expr(a, env)).collect(); @@ -1637,10 +1702,13 @@ impl TypeChecker { // A method call supplies `self` implicitly // (`dispatch_method_entry` has unified it with the // receiver), so the arguments line up with `params[1..]`. - let implicit_self = usize::from(is_method_call); + let implicit_self = usize::from(receiver_taken_by_callee); // (A method has its `self`: `takes_no_self` refused the // access otherwise.) - let written_params = params.len().saturating_sub(implicit_self); + let written_params = match through_trait { + true => params.len(), + false => params.len().saturating_sub(implicit_self), + }; // What the callee's use owes for a type variable of a // parameter is owed for that argument: a bound that // fails is reported at it. @@ -1773,7 +1841,7 @@ impl TypeChecker { CallForm::BarePipe => span, }; // A parameter the callee calls as a statement. - let statement = match is_method_call { + let statement = match receiver_taken_by_callee { true => None, false => self.statement_unit(callee, i), }; @@ -1815,18 +1883,32 @@ impl TypeChecker { CallForm::Call => { // A method's receiver is not one of the // arguments the call writes. - let what = match (&callee.kind, callee_name) { - (ExprKind::FieldAccess(_, method, _), _) if is_method_call => { - format!("method `{method}`") + // (A call through a trait writes its + // receiver: it counts.) + let (what, written, got) = match (&callee.kind, callee_name) { + (ExprKind::FieldAccess(obj, method, _), _) if through_trait => { + let shown = match self.trait_named(obj) { + Some(tr) => format!("`{}.{method}`", self.show_trait(tr)), + None => format!("method `{method}`"), + }; + (shown, written_params, args.len() + 1) } - (_, Some(name)) => format!("`{name}`"), - _ => "function".to_string(), + (ExprKind::FieldAccess(obj, method, _), _) + if let Some(tr) = self.trait_named(obj) => + { + let shown = format!("`{}.{method}`", self.show_trait(tr)); + (shown, written_params, args.len()) + } + (_, Some(name)) => { + (format!("`{name}`"), written_params, args.len()) + } + _ => ("function".to_string(), written_params, args.len()), }; let message = format!( "{what} expects {} {}, got {}", - written_params, - plural(written_params, "argument", "arguments"), - args.len() + written, + plural(written, "argument", "arguments"), + got ); (message, None) } @@ -1933,31 +2015,7 @@ impl TypeChecker { { expr.res = None; } - let called = self.callee_position; let ty = self.infer_expr_kind(expr, env); - // A method is called, not taken: `x.m` that is not a callee is a - // field. - let ty = if self.last_field_access_was_method && !called { - self.last_field_access_was_method = false; - self.method_trait = None; - let ExprKind::FieldAccess(_, method, _) = &expr.kind else { - unreachable!() - }; - self.errors.push( - Diagnostic::error( - Code::InvalidMethodCall, - expr.span, - format!("method '{method}' is not a value: a method is called"), - ) - .with_help(format!( - "call it, `x.{method}(..)`, or pass a closure that does, `{{ x -> x.{method}(..) }}`" - )), - ); - expr.ty = Some(Type::Error); - Type::Error - } else { - ty - }; if let Some(t) = self.method_trait.take() { expr.res = Some(crate::defs::Res::Def(t.id.0)); } @@ -2212,7 +2270,7 @@ impl TypeChecker { } ExprKind::FieldAccess(obj, field, _) => { - self.last_field_access_was_method = false; + self.receiver_taken = false; let field = *field; // What the resolver said the access names: nothing (it // reported why, or the module failed to load), a variant @@ -2272,8 +2330,16 @@ impl TypeChecker { expr.ty = Some(ty.clone()); return ty; } - // `Type.method`: a method of a type, called through it - // (`Shape.describe`, `m.Shape.describe`, `Int.display`). + // `Trait.method`: a method of a trait, called through it + // (`Greet.greet(x)`, `m.Greet.greet`, `Compare.compare`). + if let Some(tr) = self.trait_named(obj) { + let receiver = self.trait_receiver.take(); + let ty = self.trait_method(tr, field, receiver, span); + expr.ty = Some(ty.clone()); + return ty; + } + // `Type.method`: a method that makes a value, called + // through its type (`Int.empty`, `m.Shape.default`). let type_ref = match (&obj.kind, obj.res) { (ExprKind::Ident(name), None) => self.named_type(None, *name), (ExprKind::Ident(_) | ExprKind::FieldAccess(..), res) => self.res_type(res), @@ -2281,7 +2347,7 @@ impl TypeChecker { }; if let Some(ty) = type_ref { let key = (canonical_head(&self.tables.resolver, ty), field); - if let Some(entry) = self.method_entry(key.0, key.1, true) { + if let Some(entry) = self.method_entry(key.0, key.1) { if let Some(trait_name) = entry.trait_name && self.private_owner(trait_name).is_some() { @@ -2289,7 +2355,21 @@ impl TypeChecker { expr.ty = Some(Type::Error); return Type::Error; } - if self.ambiguous_method_call(key.0, field, true, span) { + // A method that takes a value of the type is + // called through its trait. + if let Some(tr) = self.entry_trait(&entry, field) + && self.self_param(tr, field).is_some() + { + // (The help names a trait whose method is + // called: a program's before `Display`.) + let tr = (self.method_providers(key.0, field).into_iter()) + .find(|t| uncallable_builtin(*t, field, "x").is_none()) + .unwrap_or(tr); + self.through_its_trait(&resolve(ty.name), tr, field, span); + expr.ty = Some(Type::Error); + return Type::Error; + } + if self.ambiguous_method_call(key.0, field, span) { expr.ty = Some(Type::Error); return Type::Error; } @@ -2342,30 +2422,26 @@ impl TypeChecker { // Could be record.field — infer the object type let obj_ty = self.infer_expr(obj, env); - self.last_field_access_was_method = false; + self.receiver_taken = false; let obj_ty = self.apply(&obj_ty); // Canonicalise before dispatch so a receiver whose type // is written through an alias lands in the arm of the // type it stands for. let obj_ty = crate::types::canonical::canonicalize(&self.tables.resolver, &obj_ty); - // Field / method access + // A dot after a value is a field: a record's (its type's + // or an anonymous one's), or, on a value whose type is + // still unknown, the field of a record that has one. // // `TypeOf(inner)` values (descriptors produced by `type a` - // parameters or bare type names like `Int`) dispatch to - // trait methods on `inner`'s type. The descriptor is a - // type carrier, not a value argument — the downstream - // Call arm therefore sees `is_method_call = false`, so - // arg unification runs with no offset and the fn body's - // parameter slots line up one-for-one with the user's - // explicit arguments. + // parameters or bare type names like `Int`) call the + // methods of `inner` that make a value of it. if let Type::Generic(gname, gargs) = &obj_ty && gname.is_builtin(crate::defs::TYPE_OF) && gargs.len() == 1 { let resolved = self.resolve_type_descriptor_method(&gargs[0], field, span); if let Some(ty) = resolved { - self.last_field_access_was_method = false; expr.ty = Some(ty.clone()); return ty; } @@ -2397,25 +2473,10 @@ impl TypeChecker { }; self.unify(&obj_ty, &extended, span); result_ty - } else if let Some(method_ty) = - self.structural_method(&obj_ty, field, false, span) - { - // A method every value has that its parts - // allow (`{a: 1}.display()`), as on a tuple. - expr.ty = Some(method_ty.clone()); - return method_ty; } else { - // ERR-GAP (round 81 F2): mirror the sibling - // Record / Generic field-access sites and - // append a did-you-mean hint. let candidates: Vec<(Symbol, Type)> = fields.iter().map(|(k, v)| (*k, v.clone())).collect(); - let base = format!("anon record has no field '{field}'"); - self.error_help( - Code::NoSuchField, - format_record_field_suggestion(base, field, &candidates), - span, - ); + self.no_field(&obj_ty, field, Some(obj), &candidates, span); Type::Error } } @@ -2458,177 +2519,38 @@ impl TypeChecker { expr.ty = Some(resolved.clone()); return resolved; } - // Check method table (trait methods) - if let Some(entry) = self.method_entry(*type_name, field, false) { - let instantiated = - self.dispatch_method_entry(&entry, field, &obj_ty, span); - let resolved = self.apply(&instantiated); - expr.ty = Some(resolved.clone()); - return resolved; - } - // Legacy fallback: check TypeEnv for "TypeName.method" - let key = intern(&format!("{type_name}.{field}")); - if let Some(scheme) = env.lookup(key) { - let scheme = scheme.clone(); - let result = self.instantiate(&scheme); - let resolved = self.apply(&result); - expr.ty = Some(resolved.clone()); - return resolved; - } - // A method of a structural trait the type has - // no entry for (`Some(1).compare(Some(2))`). - if let Some(method_ty) = self.structural_method(&obj_ty, field, false, span) - { - expr.ty = Some(method_ty.clone()); - return method_ty; - } - // GAP (round 35 F7): thread did-you-mean suggestion - // through the Generic/named-record field-access - // path so `u.nam` on `type User { name, age }` - // prints `did you mean 'name'?`. - self.note_unknown_method(span, *type_name, field); - let shown = self.show_type(&Type::Generic(*type_name, vec![])); - let base = format!("unknown field or method '{field}' on type {shown}"); - let msg = if let Some(rec_info) = self.tables.records.get(type_name) { - format_record_field_suggestion(base, field, &rec_info.fields) - } else { - (base, None) - }; - self.error_help(Code::UnknownField, msg, span); - Type::Error - } - // Primitive types — check method table for trait methods. - // Channel and Fn have no structural traits to - // speak of, but user-defined trait impls register entries - // under the canonical names "Channel" / "Fn" via - // `type_name_for_impl` (see `src/typechecker/mod.rs:2081`, - // `src/typechecker/mod.rs:2092`), so dispatch must route those - // receivers through the same `method_table` lookup. The - // `"Fn"` key matches `canonical_name(Type::Fun)`, - // `head_of_canon`, and `dispatch_type_for_value` - // — round 71 follow-up unified all four sites on `"Fn"`. - Type::Int - | Type::Float - | Type::Bool - | Type::String - | Type::Unit - | Type::Channel(_) - | Type::Fun(_, _) => { - // `Unit` is the key of `()` (it matches - // canonical_name(Type::Unit) and - // dispatch_type_for_value(Value::Unit)), `Fn` of a - // function. - let type_name = head_of(&obj_ty).expect("a primitive head has a type"); - if let Some(entry) = self.method_entry(type_name, field, false) { - let instantiated = - self.dispatch_method_entry(&entry, field, &obj_ty, span); - let resolved = self.apply(&instantiated); - expr.ty = Some(resolved.clone()); - return resolved; - } - // GAP (round 23 #3): append "did you mean ...?" - // when a near edit-distance method is registered - // on this type. Keep the existing "on type " - // header so prior-lock tests that match only the - // header prefix still pass; the hint is appended - // on its own `help:` line. - // A method of an impl the resolver rejected: reported there. - if self.unresolved_impl_methods.contains(&field) { - return Type::Error; - } - let display = format!("type {type_name}"); - let message = self.unknown_method_message(field, &display, type_name, span); - self.error_help(Code::UnknownMethod, message, span); + let fields = (self.tables.records.get(type_name)) + .map(|rec| rec.fields.clone()) + .unwrap_or_default(); + self.no_field(&obj_ty, field, Some(obj), &fields, span); Type::Error } - // Collection types. - // - // Round 77 BLOAT D3: the four container arms (List, - // Tuple, Map, Set) are line-for-line identical - // except for the literal type-name string. They - // collapse onto a single arm that asks - // `type_name_for_impl` for the canonical name. - // Adding a fifth container head only requires - // extending the match pattern below — not cloning - // a fourth body. The unknown-method error wording - // matches the pre-fix form (`unknown method 'X' on - // List` — without the `type` prefix used by the - // primitive arm above), preserving observable - // behavior across all four heads. - t @ (Type::List(_) | Type::Tuple(_) | Type::Map(_, _) | Type::Set(_)) => { - let type_name = self - .type_name_for_impl(t) - .expect("container head has canonical name"); - if let Some(entry) = self.method_entry(type_name, field, false) { - let instantiated = - self.dispatch_method_entry(&entry, field, &obj_ty, span); - let resolved = self.apply(&instantiated); - expr.ty = Some(resolved.clone()); - return resolved; - } - // GAP (round 92): `t.0` parses as a FieldAccess - // with an all-numeric "method" name (the parser - // keeps a dedicated tuple-index arm), but tuple - // indexing is intentionally unsupported (round 69 - // decision — docs-only). The generic "unknown - // method '0' on Tuple" wording misled users into - // thinking they typo'd a method name. Emit a - // targeted diagnostic pointing at destructuring - // instead. Numeric "methods" can only arise from - // tuple-index syntax, so this never shadows a real - // method lookup. - if matches!(t, Type::Tuple(_)) { - let field_str = resolve(field); - if !field_str.is_empty() - && field_str.bytes().all(|b| b.is_ascii_digit()) - { - self.error( - Code::UnsupportedOperation, - format!( - "tuple indexing ('t.{field_str}') is not supported; \ - destructure instead: 'let (a, b) = t'" - ), - span, - ); - return Type::Error; - } - } - // A method of an impl the resolver rejected: reported there. - if self.unresolved_impl_methods.contains(&field) { - return Type::Error; - } - let display = resolve(type_name.name).to_string(); - let message = self.unknown_method_message(field, &display, type_name, span); - self.error_help(Code::UnknownMethod, message, span); + // GAP (round 92): `t.0` parses as a FieldAccess with an + // all-numeric field name, but tuple indexing is + // intentionally unsupported (round 69 decision): the + // targeted diagnostic points at destructuring instead. + Type::Tuple(_) + if !resolve(field).is_empty() + && resolve(field).bytes().all(|b| b.is_ascii_digit()) => + { + self.error( + Code::UnsupportedOperation, + format!( + "tuple indexing ('t.{field}') is not supported; \ + destructure instead: 'let (a, b) = t'" + ), + span, + ); Type::Error } - Type::Rigid(r) => match self.bound_method(*r, field, span) { - Some((trait_name, method_ty)) => { - self.last_field_access_was_method = true; - self.method_trait = Some(trait_name); - let resolved = self.apply(&method_ty); - expr.ty = Some(resolved.clone()); - return resolved; - } - None => Type::Error, - }, Type::Var(_) => { - // A method only another module's private trait - // provides cannot be called here, whatever the - // receiver turns out to be. - if called && let Some(trait_name) = self.only_private_provider(field) { - self.private_method(trait_name, field, span); - expr.ty = Some(Type::Error); - return Type::Error; - } if called { - // `x.m(..)`: what it calls is decided with + // `x.f(..)`: what it calls is decided with // the type of `x` (`check_call`). self.unknown_receiver = Some((obj_ty.clone(), field)); self.fresh_var() } else { - // `x.f`: a record with the field `f`, - // whatever methods traits declare. + // `x.f`: a record with the field `f`. let result_ty = self.fresh_var(); let row_ty = Type::AnonRecord { fields: std::collections::BTreeMap::from([( @@ -2641,19 +2563,13 @@ impl TypeChecker { result_ty } } - Type::Error => { + Type::Error | Type::Never => { // Prior error — propagate to prevent cascading false positives Type::Error } + // Any other type has no fields. _ => { - self.error( - Code::UnknownField, - format!( - "unknown field or method '{field}' on type {}", - self.show_type(&obj_ty) - ), - span, - ); + self.no_field(&obj_ty, field, Some(obj), &[], span); Type::Error } } diff --git a/src/typechecker/inference/tests.rs b/src/typechecker/inference/tests.rs index 512df65db..46dd79c93 100644 --- a/src/typechecker/inference/tests.rs +++ b/src/typechecker/inference/tests.rs @@ -319,11 +319,14 @@ fn test_trait_constraint_method_resolved() { // A constrained type variable should allow calling trait methods assert_no_errors( r#" -trait Display for a { - fn display(self) -> String { "?" } +trait Shown { + fn shown(self) -> String } -fn show(x: a) -> String where a: Display { - x.display() +trait Shown for Int { + fn shown(self) -> String { "?" } +} +fn show(x: a) -> String where a: Shown { + Shown.shown(x) } fn main() { show(42) } "#, @@ -332,18 +335,15 @@ fn main() { show(42) } #[test] fn test_trait_constraint_unknown_method_errors() { - // A constrained type variable should NOT allow calling methods not in the trait + // A value of a constrained type variable has no fields assert_has_error( r#" -trait Display for a { - fn display(self) -> String { "?" } -} fn show(x: a) -> String where a: Display { x.nonexistent() } fn main() { show(42) } "#, - "no method 'nonexistent' found in trait constraints", + "type 'a' has no field 'nonexistent'", ); } diff --git a/src/typechecker/init_order.rs b/src/typechecker/init_order.rs index ccf16f8a1..dad4b982b 100644 --- a/src/typechecker/init_order.rs +++ b/src/typechecker/init_order.rs @@ -48,8 +48,8 @@ //! //! 4. A `Display` impl the formatter calls. Showing a value //! (interpolation, a builtin whose signature asks `Display` of its -//! argument, called or handed on as a value, and `.display()` on a -//! type with no impl of its own) calls the written `Display` impl of +//! argument, called or handed on as a value) calls the written +//! `Display` impl of //! every part of the value that has one. The parts a value of a type //! can have are the type's: its arguments, and, for a record or an //! enum of the module, the types of its fields, and theirs. Showing @@ -118,7 +118,7 @@ struct Node<'a> { const OUTSIDE: usize = 0; /// Whether a value of the type `ty` is made of builtin types only, all -/// known: a builtin trait's method on it (`[1, 2].display()`) calls no +/// known: a builtin trait's method on it (`Hash.hash([1, 2])`) calls no /// code a program writes. fn builtin_through(checker: &TypeChecker, ty: &Type) -> bool { let all = |parts: &[Type]| parts.iter().all(|t| builtin_through(checker, t)); @@ -608,11 +608,17 @@ impl TypeChecker { kind: ExprKind::FieldAccess(recv, method, _), sel, res, + span, .. }) = mention.expr else { return; }; + // The type the method is of: the receiver's, or, called + // through the trait (`Hash.hash(x)`), the type its + // argument of type `Self` has. + let recv_ty: Option = (recv.ty.clone()) + .or_else(|| self.trait_call_self.get(span).map(|t| self.apply(t))); // The method of the impl of `tr` for `ty`: the impl's // own, the trait's default, or code outside the module // (but a builtin trait's method on a value, of the type @@ -632,27 +638,26 @@ impl TypeChecker { } }; match sel { - Some(Selection::Impl { tr, ty }) => one_impl(*tr, *ty, recv.ty.as_ref()), + Some(Selection::Impl { tr, ty }) => one_impl(*tr, *ty, recv_ty.as_ref()), // A receiver decided where the code runs: every // impl of the method in the module, the trait's // default, and, for a trait of another module or a // builtin one, impls and defaults outside it. - // (`display` of such a receiver shows it, `encode` - // writes it, `decode` of a type decodes into it.) - Some(Selection::Dynamic { tr }) - if [display, encode, decode] + // (`encode` of such a receiver writes it, `decode` of + // a type decodes into it.) + Some(Selection::Dynamic { tr, .. }) + if [encode, decode] .iter() .any(|t| t.id == *tr && *method == method_of(*t)) - && recv.ty.is_some() => + && recv_ty.is_some() => { - if let Some(ty) = &recv.ty - && let Some(tr) = - [display, encode, decode].into_iter().find(|t| t.id == *tr) + if let Some(ty) = &recv_ty + && let Some(tr) = [encode, decode].into_iter().find(|t| t.id == *tr) { show(tr, ty); } } - Some(Selection::Dynamic { tr }) => { + Some(Selection::Dynamic { tr, .. }) => { for &target in of_trait.get(&(*tr, *method)).into_iter().flatten() { add(target); } @@ -660,20 +665,19 @@ impl TypeChecker { add(OUTSIDE); } } - // The VM's own method of a builtin trait: `display` - // shows the receiver, `encode` writes it, `decode` of - // a type decodes into it; the others call no code a - // program writes. + // The VM's own method of a builtin trait: `encode` + // writes the receiver, `decode` of a type decodes into + // it; the others call no code a program writes. Some(Selection::Native { tr }) => { - if let Some(ty) = &recv.ty - && let Some(tr) = - [display, encode, decode].into_iter().find(|t| t.id == *tr) + if let Some(ty) = &recv_ty + && let Some(tr) = [encode, decode].into_iter().find(|t| t.id == *tr) { show(tr, ty); } } Some(Selection::Field | Selection::FieldCall) => {} - // `Type.method`: that impl's method. + // `Type.method`, a method that makes a value: that + // impl's method. None => { if recv.ty.is_none() && let Some(crate::defs::Res::Def(id)) = res @@ -686,7 +690,7 @@ impl TypeChecker { match ty { Some(ty) => { let ty = canonical_head(&self.tables.resolver, ty); - // (`Int.display`: a type without + // (`Int.empty`: a type without // parameters is all of the value's.) let whole = Type::Generic(ty, Vec::new()); let of = matches!( diff --git a/src/typechecker/mod.rs b/src/typechecker/mod.rs index 9aa4d28b2..1970d3d79 100644 --- a/src/typechecker/mod.rs +++ b/src/typechecker/mod.rs @@ -187,7 +187,8 @@ pub struct TypeChecker { /// to a builtin, which a use of it then names in a note. pub(super) passing_on: Option, /// Whether the expression checked next is the callee of a call: - /// `x.m` there is a method call, anywhere else a field. + /// `x.f` there is a call of the function a field holds, which waits + /// for the type of `x` (`unknown_receiver`). pub(super) callee_position: bool, /// The receiver and the name of the callee just checked, when it is /// `x.m` and the type of `x` is unknown: `check_call` lets the call @@ -282,21 +283,23 @@ pub struct TypeChecker { /// its body sees it, by the impl's type, the method and the trait, /// until the body is checked. pub(super) impl_sigs: HashMap<(TypeRef, Symbol, TraitKey), FnSig>, - /// Set by the FieldAccess arm of infer_expr: `true` when the last - /// FieldAccess resolved via method dispatch (trait method table), - /// `false` when it resolved via record-field or module-qualified - /// lookup. Read by the Call arm immediately after inferring the - /// callee to decide arity semantics (method call adds implicit self; - /// field/module calls do not). - pub(super) last_field_access_was_method: bool, + /// Set by the inference of a call through a trait (`Greet.greet(x)`) + /// whose argument of type `Self` was checked with the callee + /// (`trait_receiver`): read by `check_call` right after the callee, + /// the call's other arguments line up with the method's parameters + /// after that one. + pub(super) receiver_taken: bool, /// The trait whose method the field access being inferred calls, /// which `infer_expr` records on the access (`Expr::res`): the /// compiler keys the call by it. pub(super) method_trait: Option, - /// The traits of the method calls resolved in the deferred pass, by - /// the span of the access; `resolve_all_types` records each on its - /// access. - pub(super) deferred_method_traits: HashMap, + /// The type each call through a trait (`Greet.greet(x)`) gives the + /// trait's `Self`, by the span of the access: the impl the call + /// reaches is the one for that type (`resolve_all_types`). + pub(super) trait_call_self: HashMap, + /// The argument of type `Self` of the call through a trait whose + /// callee is being inferred, with its place (`check_call`). + pub(super) trait_receiver: Option<(Type, Span)>, /// The traits the module names by its imports (`import m.{ T }`), /// and the modules it imports: their traits it sees too. pub(super) seen_traits: std::collections::HashSet, @@ -436,9 +439,10 @@ impl TypeChecker { let_order: Vec::new(), let_rings: Vec::new(), impl_sigs: HashMap::new(), - last_field_access_was_method: false, + receiver_taken: false, method_trait: None, - deferred_method_traits: HashMap::new(), + trait_call_self: HashMap::new(), + trait_receiver: None, seen_traits: std::collections::HashSet::new(), seen_modules: std::collections::HashSet::new(), builtin_imports: std::collections::HashSet::new(), @@ -1453,64 +1457,6 @@ pub struct ModuleCheck { pub let_order: Vec, } -/// For the module `module`, checked, with every other module of its -/// program: at each place it reported that a type has no method of -/// some name, the help that names a trait with such a method for the -/// type whose module `module` does not reach (`reach`: the modules it -/// imports, and theirs, and so on). It is made from the whole program's -/// impls, so it does not depend on the order the modules were checked -/// in. A module that itself imports `module` (`imports_back`) cannot be -/// imported by it: the help then says where the trait would have to be. -pub fn out_of_reach_helps( - tables: &Tables, - defs: &crate::defs::DefTable, - module: crate::session::ModuleId, - reach: &std::collections::HashSet, - imports_back: impl Fn(crate::session::ModuleId) -> bool, -) -> Vec<(Span, String)> { - let mut helps = Vec::new(); - for (span, ty, method) in tables.unknown_methods.get(&module).into_iter().flatten() { - let mut found: Vec<(String, String, bool)> = tables - .impl_methods - .providers(*ty, *method) - .iter() - .filter_map(|t| { - let owner = defs.get(t.id.0).module; - let private = tables - .traits - .get(t) - .is_some_and(|info| info.private_to.is_some()); - if owner == module || owner.is_builtin() || reach.contains(&owner) || private { - return None; - } - let name = tables.module_names.get(&owner)?; - Some((resolve(t.name), resolve(*name), imports_back(owner))) - }) - .collect(); - // (A module that can be imported first.) - found.sort_by(|a, b| (a.2, &a.0, &a.1).cmp(&(b.2, &b.0, &b.1))); - match found.first() { - Some((tr, owner, false)) => helps.push(( - *span, - format!( - "trait '{tr}' of module '{owner}' has a method '{method}' for this type; \ - import '{owner}' to call it" - ), - )), - Some((tr, owner, true)) => helps.push(( - *span, - format!( - "trait '{tr}' of module '{owner}' has a method '{method}' for this type, \ - but '{owner}' imports this module and cannot be imported by it; the \ - trait would have to be declared in a module this one can import" - ), - )), - None => {} - } - } - helps -} - /// The context a module is checked in, from the session. pub struct ModuleContext<'a> { /// The module checked. diff --git a/src/typechecker/names.rs b/src/typechecker/names.rs index e0caf16d2..0939f8b37 100644 --- a/src/typechecker/names.rs +++ b/src/typechecker/names.rs @@ -345,6 +345,19 @@ pub fn resolve_module( scope.types.entry(*name).or_insert(Binding::Poisoned); } } + // The trait of an impl that names no trait is reported at the impl; + // a call through the trait is not reported again. + for decl in &program.decls { + if let Decl::TraitImpl(ti) = decl + && ti.trait_module.is_none() + && !scope.values.contains_key(&ti.trait_name) + && !scope.types.contains_key(&ti.trait_name) + && !builtins.prelude.values.contains_key(&ti.trait_name) + && !builtins.prelude.types.contains_key(&ti.trait_name) + { + scope.values.insert(ti.trait_name, Binding::Poisoned); + } + } let mut resolver = Resolver { defs, kind, diff --git a/src/typechecker/resolve.rs b/src/typechecker/resolve.rs index bf29c7bee..d2a9500d6 100644 --- a/src/typechecker/resolve.rs +++ b/src/typechecker/resolve.rs @@ -530,12 +530,6 @@ impl TypeChecker { if let Some(ty) = &expr.ty { expr.ty = Some(self.apply(ty)); } - // A method call resolved in the deferred pass: its trait. - if matches!(expr.kind, ExprKind::FieldAccess(..)) - && let Some(t) = self.deferred_method_traits.get(&expr.span) - { - expr.res = Some(crate::defs::Res::Def(t.id.0)); - } self.select(expr); }); } @@ -558,8 +552,20 @@ impl TypeChecker { right.sel = Some(Selection::FieldCall); } } - ExprKind::FieldAccess(recv, _, _) => { + ExprKind::FieldAccess(recv, field, _) => { let called = expr.sel.take().is_some(); + // `Tr.m`: the method of the impl for the type the call + // gives `Self`. + if let Some(self_ty) = self.trait_call_self.get(&expr.span) + && let Some(crate::defs::Res::Def(id)) = expr.res + && let Some(tr) = self.trait_key(id) + { + // (The receiver is the argument of type `Self`.) + let at = self.self_param(tr, *field).unwrap_or(0); + let at = u8::try_from(at).unwrap_or(u8::MAX); + expr.sel = Some(self.method_selection(tr, self_ty, at)); + return; + } // A receiver the checker gave no type is a name: a // module, a type (`m.f`, `Shape.Circle`, `Pt.make`). let Some(recv_ty) = &recv.ty else { @@ -570,7 +576,7 @@ impl TypeChecker { _ => None, }; expr.sel = Some(match tr { - Some(tr) => self.method_selection(tr, recv_ty), + Some(tr) => self.method_selection(tr, recv_ty, 0), None if called => Selection::FieldCall, None => Selection::Field, }); @@ -580,17 +586,17 @@ impl TypeChecker { } /// What a call of a method of the trait `tr` on a receiver of the - /// type `recv` runs. - fn method_selection(&self, tr: TraitKey, recv: &Type) -> crate::ast::Selection { + /// type `recv`, the argument `at` of the call, runs. + fn method_selection(&self, tr: TraitKey, recv: &Type, at: u8) -> crate::ast::Selection { use crate::ast::Selection; let recv = crate::types::canonical::canonicalize(&self.tables.resolver, &self.apply(recv)); match &recv { Type::Var(_) | Type::Rigid(_) | Type::Error | Type::Never => { - Selection::Dynamic { tr: tr.id } + Selection::Dynamic { tr: tr.id, at } } // A type passed as a value: the method of the type it is. Type::Generic(name, _) if name.is_builtin(crate::defs::TYPE_OF) => { - Selection::Dynamic { tr: tr.id } + Selection::Dynamic { tr: tr.id, at } } // A trait the type has by its structure (the sealed three, // `Display` with no written impl) is the VM's own method; diff --git a/src/typechecker/scheme.rs b/src/typechecker/scheme.rs index e85afa470..7eb29a919 100644 --- a/src/typechecker/scheme.rs +++ b/src/typechecker/scheme.rs @@ -65,7 +65,7 @@ impl TypeChecker { // trait.) self.decide_tries(); self.default_rebuilds(); - self.default_selects(true); + self.default_selects(); for i in self.closed_mark..self.wanted.len() { if self.wanted[i].solved { continue; diff --git a/src/typechecker/size_locks.rs b/src/typechecker/size_locks.rs index ce80976b7..208910686 100644 --- a/src/typechecker/size_locks.rs +++ b/src/typechecker/size_locks.rs @@ -35,8 +35,8 @@ fn record_info_size_locked() { fn trait_info_size_locked() { // Stage 5 shrank its spans from 24 to 12 bytes; stage 6 added `self_var`, // `var_names` and `method_bounds`, which a default body and an impl - // are checked with, and `receivers`, which says where `x.m(..)` may - // call a method. `builtin_needs` and `via_needs`: what the default + // are checked with, and `receivers`, which says where an impl's + // method writes `self`. `builtin_needs` and `via_needs`: what the default // bodies ask of their annotation variables for the builtins and the // trait methods they give them to. assert_eq!( diff --git a/src/typechecker/solve.rs b/src/typechecker/solve.rs index 5b5988978..135142459 100644 --- a/src/typechecker/solve.rs +++ b/src/typechecker/solve.rs @@ -25,9 +25,9 @@ pub(crate) enum Goal { /// A predicate a use owes. Pred(Pred), /// `recv.name(args)`, with the result `result`, where the receiver's - /// type was unknown at the call: which method or function-typed - /// field it calls is decided when the receiver's type is (`select`), - /// and when the definition is generalised if it still is not. + /// type was unknown at the call: the function-typed field it calls + /// is checked when the receiver's type is known (`select_call`), and + /// when the definition is generalised if it still is not. Select { recv: Type, name: Symbol, @@ -377,59 +377,8 @@ impl TypeChecker { } } - /// A method call whose receiver was a type variable when it was - /// inferred and is the type `type_name` now: `true` when the type has - /// the method. The call's trait is recorded by its span - /// (`deferred_method_traits`), which `resolve_all_types` writes on - /// the access; a call that sees the method in two traits is - /// ambiguous, as anywhere. - pub(super) fn deferred_method_call( - &mut self, - type_name: TypeRef, - field: Symbol, - obj_ty: &Type, - result_ty: &Type, - span: Span, - ) -> bool { - let Some(entry) = self.method_entry(type_name, field, false) else { - return false; - }; - let instantiated = self.dispatch_method_entry(&entry, field, obj_ty, span); - if let Some(t) = self.method_trait.take() { - self.deferred_method_traits.insert(span, t); - } - let method_ty = self.apply(&instantiated); - self.unify_deferred_method(result_ty, &method_ty, span); - true - } - - /// Unify the type a method call on an unknown receiver was given - /// (`result_ty`) with the method it turned out to call. - /// - /// Method types include `self` as the first param. When the call - /// site originally saw this field access as an unknown Var, it - /// unified the var with a function type built from the *explicit* - /// args only (no receiver). Strip `self` when adapting. - pub(super) fn unify_deferred_method(&mut self, result_ty: &Type, method_ty: &Type, span: Span) { - let result_resolved = self.apply(result_ty); - match (&result_resolved, method_ty) { - (Type::Fun(call_params, call_ret), Type::Fun(method_params, method_ret)) - if method_params.len() == call_params.len() + 1 => - { - for (cp, mp) in call_params.iter().zip(method_params.iter().skip(1)) { - self.unify(cp, mp, span); - } - self.unify(call_ret, method_ret, span); - } - _ => { - self.unify(result_ty, method_ty, span); - } - } - } - /// Decide what `recv.field(args)` calls, now that the receiver's type - /// is known: a method of the type (its impls, or the bounds of an - /// annotation variable), or the function a field of the record holds. + /// is known: the function a field of the record holds. fn select_call( &mut self, recv: &Type, @@ -438,21 +387,12 @@ impl TypeChecker { result: Type, span: Span, ) { - let obj_ty = recv.clone(); let result_ty = Type::Fun(args, Box::new(result)); let resolved = crate::types::canonical::canonicalize(&self.tables.resolver, &self.apply(recv)); match &resolved { Type::Error | Type::Never => {} Type::Var(_) => unreachable!("a selection waits while its receiver is unknown"), - // The receiver became an annotation variable: it has the - // methods of its bounds, and nothing else. - Type::Rigid(r) => { - if let Some((trait_name, method_ty)) = self.bound_method(*r, field, span) { - self.deferred_method_traits.insert(span, trait_name); - self.unify_deferred_method(&result_ty, &method_ty, span); - } - } Type::AnonRecord { fields: af, tail } => { if let Some(field_ty) = af.get(&field) { let ft = field_ty.clone(); @@ -464,17 +404,9 @@ impl TypeChecker { }; self.unify(&resolved, &extended, span); } else { - // ERR-GAP (round 81 F2): match the sibling Record / - // Generic deferred sites and append a did-you-mean - // hint when a near-edit-distance field exists. let candidates: Vec<(Symbol, Type)> = af.iter().map(|(k, v)| (*k, v.clone())).collect(); - let base = format!("anon record has no field '{field}'"); - self.error_help( - Code::NoSuchField, - format_record_field_suggestion(base, field, &candidates), - span, - ); + self.no_field(&resolved, field, None, &candidates, span); } } Type::Generic(type_name, type_args) => { @@ -513,47 +445,13 @@ impl TypeChecker { self.unify(&result_ty, &field_ty, span); return; } - // Also check the method table for trait methods. - if self.deferred_method_call(type_name, field, &obj_ty, &result_ty, span) { - return; - } - // A method of a structural trait the type has no entry - // for. - if let Some(method_ty) = self.structural_method(&obj_ty, field, false, span) { - self.last_field_access_was_method = false; - if let Some(t) = self.method_trait.take() { - self.deferred_method_traits.insert(span, t); - } - self.unify_deferred_method(&result_ty, &method_ty, span); - return; - } - // GAP (round 35 F7): thread did-you-mean suggestion - // through the Generic/named-record deferred path. - let shown = self.show_type(&Type::Generic(type_name, vec![])); - let base = format!("unknown field or method '{field}' on type {shown}"); - let msg = if let Some(rec_info) = self.tables.records.get(&type_name) { - format_record_field_suggestion(base, field, &rec_info.fields) - } else { - (base, None) - }; - self.error_help(Code::UnknownField, msg, span); - } - // A builtin type (`Int`, `List`, ...): its trait methods. - _ => { - if let Some(type_name) = self.type_name_for_impl(&resolved) - && self.deferred_method_call(type_name, field, &obj_ty, &result_ty, span) - { - return; - } - self.error( - Code::UnknownField, - format!( - "unknown field or method '{field}' on type {}", - self.show_type(&resolved) - ), - span, - ); + let fields = (self.tables.records.get(&type_name)) + .map(|rec| rec.fields.clone()) + .unwrap_or_default(); + self.no_field(&resolved, field, None, &fields, span); } + // Any other type has no fields. + _ => self.no_field(&resolved, field, None, &[], span), } } @@ -1161,14 +1059,10 @@ impl TypeChecker { self.close_level(); } - /// Decide each call `x.m(args)` of the scope just left whose - /// receiver is still unknown and is the scope's to generalise. When - /// exactly one trait the module sees declares a method `m`, the call - /// is that method's and `x` is bounded by the trait - /// (`fn g(x) { x.greet() }` is `a -> String where a: Greet`). When - /// none does, `x` is a record with a function in its field `m`. When - /// several do, the receiver needs an annotation. - pub(super) fn default_selects(&mut self, wait_if_several: bool) { + /// Decide each call `x.f(args)` of the scope just left whose + /// receiver is still unknown and is the scope's to generalise: `x` is + /// a record with a function in its field `m`. + pub(super) fn default_selects(&mut self) { let mine: Vec = (self.closed_mark..self.wanted.len()) .filter(|&i| { !self.wanted[i].solved @@ -1193,9 +1087,7 @@ impl TypeChecker { continue; }; // (An earlier one of these may have decided this receiver.) - if matches!(self.apply(&recv), Type::Var(_)) - && !(wait_if_several && self.traits_declaring(name).len() > 1) - { + if matches!(self.apply(&recv), Type::Var(_)) { self.wanted[i].solved = true; let call_ty = Type::Fun(args, Box::new(result)); self.default_select(&recv, name, call_ty, origin.span); @@ -1205,127 +1097,14 @@ impl TypeChecker { self.close_level(); } - /// The traits in sight that declare a method `name` a call on a - /// value may mean (`on_a_value`), in the order of their names. - fn traits_declaring(&self, name: Symbol) -> Vec { - let mut traits: Vec = self - .tables - .traits - .iter() - .filter(|(_, info)| info.methods.iter().any(|(n, _)| *n == name)) - .map(|(t, _)| *t) - .filter(|t| self.sees_trait(*t)) - .collect(); - traits.sort_by_key(|t| self.show_trait(*t)); - self.on_a_value(traits, |t| *t, name) - } - - /// Of `candidates` (each of the trait `trait_of` says) for a call of - /// `method` on a value, those the call may mean: a method without - /// `self` is never one, of any trait. Where none takes `self`, the - /// first alone, which the call reports as taking none. - pub(super) fn on_a_value( - &self, - mut candidates: Vec, - trait_of: impl Fn(&C) -> TraitKey, - method: Symbol, - ) -> Vec { - let takes_self = |c: &C| { - (self.tables.traits.get(&trait_of(c))) - .is_none_or(|info| info.receivers.contains(&method)) - }; - match candidates.iter().any(takes_self) { - true => candidates.retain(takes_self), - false => candidates.truncate(1), - } - candidates - } - + /// `x.name(..)` whose receiver nothing decided: `x` is a record with + /// a function of the call's type in its field `name`. fn default_select(&mut self, recv: &Type, name: Symbol, call_ty: Type, span: Span) { - let traits = self.traits_declaring(name); - match traits.as_slice() { - [] => { - let row = Type::AnonRecord { - fields: std::collections::BTreeMap::from([(name, call_ty)]), - tail: RowTail::Var(self.fresh_tyvar_id()), - }; - self.unify(recv, &row, span); - } - [tr] => { - let info = self.tables.traits[tr].clone(); - let (_, method_ty) = info - .methods - .iter() - .find(|(n, _)| *n == name) - .expect("the trait declares the method"); - // A method without `self` is not what a value's `.{name}` - // calls, and says nothing of the receiver. - let receiver = info.receivers.contains(&name); - let on_type = on_type_call("SomeType", name, method_ty); - if self.takes_no_self(receiver, name, &on_type, span) { - return; - } - // The trait's parameters are what the receiver's impl - // will say; the method's own variables are new. - let mut mapping: HashMap = HashMap::new(); - mapping.insert(info.self_var, recv.clone()); - let params: Vec = info - .param_var_ids - .iter() - .map(|v| { - let fresh = self.fresh_var(); - mapping.insert(*v, fresh.clone()); - fresh - }) - .collect(); - let ty = substitute_vars(method_ty, &mapping); - // (And what the method of the receiver's impl asks.) - let preds: Vec = info - .method_bounds - .get(&name) - .into_iter() - .flatten() - .map(|pred| pred.substitute(&mapping)) - .chain([Pred::Via { - tr: *tr, - method: name, - receiver: recv.clone(), - method_ty: ty.clone(), - passer: None, - at: None, - }]) - .collect(); - let own: Vec = free_vars_in(method_ty) - .into_iter() - .filter(|v| !mapping.contains_key(v)) - .collect(); - let scheme = Scheme { - vars: own, - preds, - ty, - }; - let origin = Origin { - span, - callee: Some(name), - op: None, - }; - self.want( - Pred::Trait { - tr: *tr, - args: params, - subject: recv.clone(), - asker: None, - }, - origin, - ); - let method_ty = self.instantiate_method(&scheme, name, span); - self.deferred_method_traits.insert(span, *tr); - self.unify_deferred_method(&call_ty, &method_ty, span); - } - several => { - self.ambiguous_method(name, "a value whose type is not known", several, span); - } - } + let row = Type::AnonRecord { + fields: std::collections::BTreeMap::from([(name, call_ty)]), + tail: RowTail::Var(self.fresh_tyvar_id()), + }; + self.unify(recv, &row, span); } /// Report that `method`, called on `on` (`type 'Int'`, `a value @@ -2466,40 +2245,35 @@ impl TypeChecker { self.builtin_imports.contains(&module) || self.seen_traits.contains(&t.id.0) } - /// The traits that give the type `ty` a method `method`, in the - /// order of their names: those of the session's impls, and the - /// structural trait whose method it is when no impl of that trait - /// is written for the type, for a call through the type (`on_type`, - /// `T.method(..)`) or on a value (`on_a_value`). - fn method_providers(&self, ty: TypeRef, method: Symbol, on_type: bool) -> Vec { + /// The traits that give the type `ty` a method `method` for a call + /// through the type (`T.method(..)`), in the order of their names: + /// those of the session's impls, and the structural trait whose + /// method it is when no impl of that trait is written for the type. + pub(super) fn method_providers(&self, ty: TypeRef, method: Symbol) -> Vec { let mut traits = self.tables.impl_methods.providers(ty, method).to_vec(); - if let Some(tr) = self.structural_provider(ty, method, on_type) + if let Some(tr) = self.structural_provider(ty, method) && !traits.contains(&tr) { traits.push(tr); } traits.sort_by_key(|t| self.show_trait(*t)); - match on_type { - true => traits, - false => self.on_a_value(traits, |t| *t, method), - } + // Through the type, a method that makes a value: one that takes + // a value of the type is called through its trait, so it is no + // candidate where another trait gives the type a method of the + // name that makes one. + if traits.iter().any(|t| self.self_param(*t, method).is_none()) { + traits.retain(|t| self.self_param(*t, method).is_none()); + } + traits } /// The structural trait whose method `method` the type `ty` has by /// its structure: one of their names, of a type that has the name /// (`Tables::has_structural_name`) and no written impl of the trait. - /// A structural method that takes no `self` (`decode`) is no method - /// of a call on a value (not `on_type`): such a call means another - /// trait's method of the name, if one has it. - fn structural_provider(&self, ty: TypeRef, method: Symbol, on_type: bool) -> Option { + fn structural_provider(&self, ty: TypeRef, method: Symbol) -> Option { let name = resolve(method); let (tr_name, _) = STRUCTURAL_METHODS.iter().find(|(_, m)| *m == name)?; let tr = TraitKey::builtin(tr_name); - let takes_self = - (self.tables.traits.get(&tr)).is_none_or(|info| info.receivers.contains(&method)); - if !on_type && !takes_self { - return None; - } (self.tables.has_structural_name(tr, ty) && self.by_structure(tr, ty) && self.unreached(tr).is_none()) @@ -2536,13 +2310,8 @@ impl TypeChecker { /// reach by its imports it has not. It is decided from the impls' /// rows each time. (For a call that is ambiguous the first /// candidate's: `ambiguous_method_call` reports it.) - pub(super) fn method_entry( - &self, - ty: TypeRef, - method: Symbol, - on_type: bool, - ) -> Option { - let providers = self.method_providers(ty, method, on_type); + pub(super) fn method_entry(&self, ty: TypeRef, method: Symbol) -> Option { + let providers = self.method_providers(ty, method); let tr = match self.meant_provider(&providers) { Ok(tr) => tr?, Err(candidates) => candidates[0], @@ -2558,59 +2327,20 @@ impl TypeChecker { method_type: Type::Error, structural: true, trait_name: None, - receiver: true, preds: Vec::new(), }), } } - /// Whether a value of the type `ty` has a method `method`, whatever - /// the module checked may call. - pub(super) fn has_method(&self, ty: TypeRef, method: Symbol) -> bool { - !self.method_providers(ty, method, false).is_empty() - } - - /// The names of the methods of the type `ty`. - pub(super) fn method_names(&self, ty: TypeRef) -> Vec { - let mut names: Vec = self - .tables - .impl_methods - .keys() - .filter(|(of, _, _)| *of == ty) - .map(|(_, method, _)| *method) - .collect(); - for (_, method) in STRUCTURAL_METHODS { - let method = intern(method); - if self.structural_provider(ty, method, false).is_some() { - names.push(method); - } - } - names.sort(); - names.dedup(); - names - } - - /// Keep that the type `ty` was reported at `span` to have no method - /// `method`: a trait of a module that is not imported may have one, - /// which is known once the whole program is checked. - pub(super) fn note_unknown_method(&mut self, span: Span, ty: TypeRef, method: Symbol) { - self.tables - .unknown_methods - .entry(self.module) - .or_default() - .push((span, ty, method)); - } - /// Whether a call of `method` of `ty` is ambiguous here; if so, it is /// reported at `span`. pub(super) fn ambiguous_method_call( &mut self, ty: TypeRef, method: Symbol, - on_type: bool, span: Span, ) -> bool { - let providers = self.method_providers(ty, method, on_type); + let providers = self.method_providers(ty, method); let Err(traits) = self.meant_provider(&providers) else { return false; }; @@ -2618,16 +2348,13 @@ impl TypeChecker { self.ambiguous_method(method, &on, &traits, span); // Called through the type (`T.decode(v)`), there is no receiver // to annotate: a function bounded by the trait says which (a - // program's trait where one is among them, `Pretty` over `Display`). - if on_type { - let named = (traits.iter()) - .find(|t| crate::defs::builtin_trait_of_id(t.id.0).is_none()) - .or(traits.first()) - .map(|t| self.show_trait(*t)) - .unwrap_or_default(); - let Some(last) = self.errors.last_mut() else { - return true; - }; + // program's trait where one is among them). + let named = (traits.iter()) + .find(|t| crate::defs::builtin_trait_of_id(t.id.0).is_none()) + .or(traits.first()) + .map(|t| self.show_trait(*t)) + .unwrap_or_default(); + if let Some(last) = self.errors.last_mut() { last.help = vec![format!( "say which is meant: call it through a function bounded by the trait you mean, \ `where a: {named}`" diff --git a/src/typechecker/tables.rs b/src/typechecker/tables.rs index 1ec8ced1d..5b10b1cbb 100644 --- a/src/typechecker/tables.rs +++ b/src/typechecker/tables.rs @@ -47,8 +47,8 @@ pub(super) struct TraitInfo { /// Implementing this trait on a type requires every supertrait to also /// be implemented for the same type (validated in /// `validate_trait_impls`). `expand_with_supertraits` walks this list - /// transitively to enable supertrait method calls inside `where` - /// clauses. + /// transitively, so a `where` bound gives its supertraits' bounds + /// too. pub(super) supertraits: Vec, /// Parallel to `supertraits`: the TypeExpr args supplied to each /// supertrait reference. For `trait Sub(a): Super(a)` the entry for @@ -62,9 +62,8 @@ pub(super) struct TraitInfo { /// type for `Self` and its trait arguments for the parameters. pub(super) methods: Vec<(Symbol, Type)>, /// The methods that take a receiver: those whose first parameter is - /// written `self`. This is the one fact of whether `x.m(..)` may - /// call a method; a method without `self` is called on a type - /// (`Int.make(1)`), whatever its parameters are. + /// written `self`. An impl writes `self` where its trait does, and + /// only there. pub(super) receivers: std::collections::HashSet, /// The bounds each method's own `where` clauses put on its type /// variables, with the bound's trait arguments. They are part of the @@ -128,9 +127,6 @@ pub(crate) struct MethodEntry { /// The trait whose impl provides the method. `None` for a /// structural trait's method (`structural`), which is no impl's. pub(super) trait_name: Option, - /// Whether the method takes a receiver, as its trait declares it - /// (`TraitInfo::receivers`). - pub(super) receiver: bool, /// What every use of the method owes, on the variables of /// `method_type`: the `where` clauses of the impl's header /// (`trait Greet for Box(a) where a: Greet`) and the bounds the @@ -280,7 +276,7 @@ pub(super) type ImplMethodKey = (TypeRef, Symbol, TraitKey); /// The methods of the session's impls: one row for each method of each /// impl, by its type, its name and its trait, entered by the module that /// writes the impl. The impls of two traits that each have a method `m` -/// for one type are two rows; what `x.m()` means in a module is decided +/// for one type are two rows; what `T.m(..)` means in a module is decided /// from the rows each time (`TypeChecker::method_entry`), never written /// back. `providers` is an index of the rows, kept with them. #[derive(Clone, Default)] @@ -357,12 +353,6 @@ pub struct Tables { pub(super) traits: Table, TraitKey>, /// The methods of every impl, by type, name and trait. pub(super) impl_methods: ImplMethods, - /// Where each module reported that a type has no method of some - /// name: the place, the type, the name. Once every module of a - /// program is checked, a trait out of the module's reach that has - /// such a method is named there ([`out_of_reach_helps`]). - pub(super) unknown_methods: - HashMap>, /// Tracks which (trait_name, type) pairs have been implemented. pub(super) trait_impl_set: Table, (TraitKey, TypeRef)>, @@ -541,54 +531,6 @@ impl Tables { } } - /// Every method a value has, as (the type impls key the value's type - /// by, the method's name): those of the impls that take `self`, and those of the - /// structural traits (of a builtin type, the traits it is stamped - /// with; of a type a program declares, all their names). A - /// structural trait of a builtin module (`json.Encode`) gives its - /// method only where `imports` says the module is imported. - pub fn methods(&self, imports: &dyn Fn(&str) -> bool) -> Vec<(TypeRef, Symbol)> { - // (A method without `self` is called on the type, not on a - // value.) - let mut methods: std::collections::HashSet<(TypeRef, Symbol)> = self - .impl_methods - .rows - .iter() - .filter(|(_, entry)| entry.receiver) - .map(|((ty, method, _), _)| (*ty, *method)) - .collect(); - let declared = self - .records - .keys() - .chain(self.enums.keys()) - .filter(|ty| builtin_type_name(**ty).is_none()); - for (name, method) in STRUCTURAL_METHODS { - let tr = TraitKey::builtin(name); - if let Some((_, Some(module))) = crate::defs::builtin_trait_of_id(tr.id.0) - && !imports(module) - { - continue; - } - let method = intern(method); - // (`decode` is called on the type.) - if self - .traits - .get(&tr) - .is_some_and(|info| !info.receivers.contains(&method)) - { - continue; - } - methods.extend( - self.trait_impl_set - .iter() - .filter(|(t, _)| *t == tr) - .map(|(_, ty)| (*ty, method)), - ); - methods.extend(declared.clone().map(|ty| (*ty, method))); - } - methods.into_iter().collect() - } - /// Whether a value of the type `ty` has the method of the structural /// trait `tr` as a name: a builtin type when it is stamped with the /// trait, a type a program declares always (whether it has the @@ -630,7 +572,6 @@ impl Tables { )); rows.extend(keys("scheme", self.schemes.keys())); rows.extend(keys("statement-units", self.statement_units.keys())); - rows.extend(keys("unknown-methods", self.unknown_methods.keys())); rows.extend(keys("waiting", self.waiting.keys())); rows.extend(keys("rows-of", self.rows.keys())); rows.extend(keys( @@ -690,7 +631,6 @@ impl Tables { /// it was a REPL cell that is dropped. pub fn forget(&mut self, module: crate::session::ModuleId) { self.waiting.remove(&module); - self.unknown_methods.remove(&module); let Some(rows) = self.rows.remove(&module) else { return; }; diff --git a/src/typechecker/tests.rs b/src/typechecker/tests.rs index fc5bf9dc3..073e36f53 100644 --- a/src/typechecker/tests.rs +++ b/src/typechecker/tests.rs @@ -543,7 +543,7 @@ trait Display for Shape { fn main() { let s = Circle(5.0) - s.display() + "{s}" } "#, ); @@ -1663,7 +1663,7 @@ fn main() { p.z } "#, - "unknown field or method 'z' on type Point", + "type 'Point' has no field 'z'", ); } diff --git a/src/typechecker/unify.rs b/src/typechecker/unify.rs index eec38890b..d2d29a57f 100644 --- a/src/typechecker/unify.rs +++ b/src/typechecker/unify.rs @@ -174,7 +174,7 @@ impl TypeChecker { self.close_level(); self.decide_tries(); self.default_rebuilds(); - self.default_selects(false); + self.default_selects(); } /// Make variables as the scope `exit_level` just left did, until @@ -637,22 +637,22 @@ impl TypeChecker { let shown = self.written_type(*name); let mut fault = Fault::new( Code::NoSuchField, - format!( - "record {shown} has no field{} {}", - if missing.len() == 1 { "" } else { "s" }, - missing - .iter() - .map(|f| format!("'{f}'")) - .collect::>() - .join(", ") - ), + match missing.as_slice() { + [field] => format!("type '{shown}' has no field '{field}'"), + _ => format!( + "record {shown} has no fields {}", + missing + .iter() + .map(|f| format!("'{f}'")) + .collect::>() + .join(", ") + ), + }, ); - // A method of the record is not a field of it: what reads - // a record's fields calls a field. - if let Some(method) = missing.iter().find(|f| self.has_method(*name, intern(f))) { - fault.help = Some(format!( - "'{method}' is a method of `{shown}`, and what is asked for here is a record with a field '{method}': a value whose fields are read is a record, and `x.{method}(..)` on it calls a field; annotate it, `p: {shown}`" - )); + // A method of a trait is not a field: it is called through + // its trait. + if let [field] = missing.as_slice() { + fault.help = self.method_help(nominal, intern(field), "x"); } out.push(fault); return; @@ -1021,6 +1021,38 @@ impl TypeChecker { } } + // ── Open row × a type with no fields ───────────────────── + // What a dot after a value of unknown type asked for (`x.f`, + // `x.f(..)`): the value's type has no field. + ( + Type::AnonRecord { + fields, + tail: RowTail::Var(_), + }, + other, + ) + | ( + other, + Type::AnonRecord { + fields, + tail: RowTail::Var(_), + }, + ) if !matches!( + other, + Type::AnonRecord { .. } | Type::Var(_) | Type::Error | Type::Never + ) && !matches!(other, Type::Generic(name, _) if self.tables.records.contains_key(name)) + && !fields.is_empty() => + { + let field = *fields.keys().next().expect("a field"); + let shown = self.show_type(other); + let mut fault = Fault::new( + Code::UnknownField, + format!("type '{shown}' has no field '{field}'"), + ); + fault.help = self.method_help(other, field, "x"); + out.push(fault); + } + (Type::Generic(n1, a1), Type::Generic(n2, a2)) => { if n1 != n2 { // Round 80 BROKEN B1+B2: this arm formatted the bare diff --git a/src/value/fmt.rs b/src/value/fmt.rs index b2eea3ab6..e5a454dac 100644 --- a/src/value/fmt.rs +++ b/src/value/fmt.rs @@ -312,7 +312,7 @@ fn begin<'a>( } Value::Variant(variant) => { // A builtin error is shown as its message, the text its - // `message()` gives: one text for both. + // `Error.message` gives: one text for both. if shown && let Some(message) = crate::builtins::error_text(variant) { return f.write_str(&message).map(|()| None); } diff --git a/src/vm/dispatch.rs b/src/vm/dispatch.rs index 48d61ae5b..ecb7154f9 100644 --- a/src/vm/dispatch.rs +++ b/src/vm/dispatch.rs @@ -104,8 +104,10 @@ pub(super) fn resume_native( impl Vm { // ── Built-in trait methods on primitive types ────────────────── - /// Handle built-in trait methods like .display(), .equal(), .compare() - /// on primitive types. Returns Some(result) if handled, None otherwise. + /// The methods of the structural traits a program calls, + /// `Compare.compare` and `Hash.hash`, for a value whose type has the + /// trait by its structure. Returns Some(result) if handled, None + /// otherwise. pub(super) fn dispatch_trait_method( &self, receiver: &Value, @@ -113,72 +115,6 @@ impl Vm { extra_args: &[Value], ) -> Option> { match method { - "display" => { - if !extra_args.is_empty() { - return Some(Err(VmError::new("display() takes no arguments".into()))); - } - // Runtime Display gate — the .display() twin of the - // round-95 `Op::DisplayValue` gate (src/vm/run.rs - // ~:1457). For a *concrete* receiver the typechecker - // already rejects `.display()` on no-Display types - // ("unknown method 'display' on type Fn"), but silt - // enforces inferred trait bounds at the EXECUTION site - // for polymorphic code, so a Var-typed receiver reaches - // this arm ungated. Pre-fix, `fn show(x: a) -> String - // { x.display() }` over a lambda / channel / task handle - // silently rendered `` / `` / - // `` — while the equivalent interpolation - // `"{x}"` errored at runtime and the sibling `.equal()` / - // `.compare()` arms below carry their own runtime gates. - // Reject the same set here, sourced from the single - // oracle `Vm::value_implements_display` so the two - // execution-site gates cannot drift. Records, variants - // (incl. stdlib error enums) and every printable - // built-in pass the oracle and fall through unchanged. - if !Self::value_implements_display(receiver) { - // Same canonical-name reporting as Op::DisplayValue: - // function-shaped values collapse to "Fn" via - // `dispatch_type_name`; the descriptor values - // (whose canonical name is the *carried* type name) - // fall back to their kind so the diagnostic names - // the descriptor kind, not the reflected type. - let name = match receiver { - Value::TypeDescriptor(_) | Value::PrimitiveDescriptor(_) => { - receiver.kind().to_string() - } - _ => crate::types::canonical::dispatch_type_name(receiver), - }; - return Some(Err(VmError::new(format!( - "type '{name}' does not implement Display" - )))); - } - if let Err(too_long) = receiver.writable() { - return Some(Err(too_long.into())); - } - Some(Ok(Value::String(self.display_value(receiver).into()))) - } - "equal" => { - if extra_args.len() != 1 { - return Some(Err(VmError::new("equal() takes 1 argument".into()))); - } - // Execution-site backstop mirroring the `Op::Eq` gate - // (`equality_operand_violation`, src/vm/run.rs): an - // operand that is, or transitively contains, a - // function-shaped leaf has no Equal impl. A polymorphic - // wrapper (`fn eq(a: x, b: x) -> Bool { a.equal(b) }`) - // can launder such values past the typechecker's - // concrete-operand gate, and `PartialEq for Value` would - // silently answer by function and captures. - if receiver.contains_fn() || extra_args[0].contains_fn() { - return Some(Err(VmError::new( - "type 'Fn' does not implement Equal".into(), - ))); - } - // `Equal` is structural: `PartialEq for Value` - // (src/value/key.rs) is its one implementation, for `==` - // and for `.equal()`. - Some(Ok(Value::Bool(*receiver == extra_args[0]))) - } "compare" => { if extra_args.len() != 1 { return Some(Err(VmError::new("compare() takes 1 argument".into()))); @@ -190,7 +126,7 @@ impl Vm { // arm can defer to `Value::cmp`, which orders closures of // two functions by the functions' addresses — an // ASLR-nondeterministic result for a - // polymorphic `fn cmp(a: x, b: x) -> Int { a.compare(b) }` + // polymorphic `fn cmp(a: x, b: x) -> Int { Compare.compare(a, b) }` // laundering a container of functions past the typechecker. if receiver.contains_fn() || other.contains_fn() { return Some(Err(VmError::new( @@ -209,7 +145,7 @@ impl Vm { // `Compare` is structural: `Ord for Value` // (src/value/key.rs) orders records by their // declared fields and variants by declaration, for - // `<` and for `.compare()`. + // `<` and for `Compare.compare`. (Value::Variant(..), Value::Variant(..)) | (Value::Record(..), Value::Record(..)) => receiver.cmp(other), // @@ -242,10 +178,10 @@ impl Vm { if !extra_args.is_empty() { return Some(Err(VmError::new("hash() takes no arguments".into()))); } - // Execution-site backstop mirroring the `"equal"` / - // `"compare"` arms above: a receiver that is, or - // transitively contains, a function-shaped leaf has no - // Hash (the checker rejects `[{ y -> y }].hash()`; a + // Execution-site backstop mirroring the `"compare"` arm + // above: a receiver that is, or transitively contains, a + // function-shaped leaf has no Hash (the checker rejects + // `Hash.hash([{ y -> y }])`; a // function has none of the structural traits). The // std `Hash` impl on `Value` hashes every closure as a // constant discriminant tag ("not meaningfully diff --git a/src/vm/mod.rs b/src/vm/mod.rs index 00e2993ad..baca9e659 100644 --- a/src/vm/mod.rs +++ b/src/vm/mod.rs @@ -814,9 +814,7 @@ impl Vm { /// Whether a runtime value's type has a Display impl — the single /// runtime-side oracle for the string-interpolation Display gate - /// (`Op::DisplayValue`, src/vm/run.rs) and the polymorphic - /// `.display()` method gate (`dispatch_trait_method`'s "display" - /// arm, src/vm/dispatch.rs). + /// (`Op::DisplayValue`, src/vm/run.rs). /// /// This mirrors the typechecker's compile-time gate: the typechecker /// reduces a *concrete* operand to its canonical name diff --git a/src/vm/run.rs b/src/vm/run.rs index 876bdfeaa..670483519 100644 --- a/src/vm/run.rs +++ b/src/vm/run.rs @@ -1218,13 +1218,23 @@ impl Vm { ok!(self.show(&msg, |_, text| Err(VmError::new(format!("panic: {text}"))))); go_on!(ok!(self.enter_step(step))); } - Instr::CallMethod { method, argc, of } => { + Instr::CallMethod { + method, + argc, + of, + at, + } => { save!(); - go_on!(ok!(self.call_method(method, argc, of, false))); + go_on!(ok!(self.call_method(method, argc, of, at, false))); } - Instr::TailCallMethod { method, argc, of } => { + Instr::TailCallMethod { + method, + argc, + of, + at, + } => { save!(); - go_on!(ok!(self.call_method(method, argc, of, true))); + go_on!(ok!(self.call_method(method, argc, of, at, true))); } Instr::Slide { slot } => { // Keep the top value and cut the frame back to @@ -1571,12 +1581,14 @@ impl Vm { method: u16, argc: usize, trait_index: u16, + at: usize, tail: bool, ) -> Result { let receiver_slot = self.stack.len() - argc; // (The receiver is looked at where it is: a method of an impl - // is found by its type alone.) - let receiver = &self.stack[receiver_slot]; + // is found by its type alone. It is the argument `at`, the + // first of the method's of type `Self`.) + let receiver = &self.stack[receiver_slot + at]; let receiver_type = crate::types::canonical::dispatch_type_for_value(receiver); // Descriptor-as-receiver (e.g. `Int.default()`, // `body.decode(Todo)` where the descriptor is piped in) is @@ -1660,16 +1672,7 @@ impl Vm { return self.enter_step(step); } // No impl has the method for the receiver's type: what the - // call does then goes by the method's name. Called through a - // type (`a.display(x)` for a `type a`, `t.compare(x, y)` for a - // type held in `t`), the descriptor only chose the type: the - // value the method is of is the first argument. - let argc = if descriptor_receiver && argc > 1 { - self.stack.remove(receiver_slot); - argc - 1 - } else { - argc - }; + // call does then goes by the method's name. let receiver = self.stack[receiver_slot].clone(); let slots = self.view.entry.clone(); // (The compiler checks each function against the globals of @@ -1686,16 +1689,6 @@ impl Vm { "the call of method '{method_name}' names a trait the program does not have" ))); } - // `display` of a value whose parts a written impl may show. - if method_name == "display" - && argc == 1 - && slots.any_shown() - && Self::value_implements_display(&receiver) - { - self.stack.truncate(receiver_slot); - let step = self.shown(&receiver)?; - return self.enter_step(step); - } // `encode` of a value whose type has no written `json.Encode` // impl: its structural form, with the impls of its parts. if method_name == "encode" diff --git a/src/vm/show.rs b/src/vm/show.rs index d3dcf4caa..2200f8ab7 100644 --- a/src/vm/show.rs +++ b/src/vm/show.rs @@ -1,5 +1,5 @@ -//! Showing a value: `println`, `print`, interpolation, `.display()`, -//! `string.from`, a panic's message. +//! Showing a value: `println`, `print`, interpolation, `string.from`, a +//! panic's message. //! //! A value is shown by the VM's formatter (`Value`'s `Display`), but a //! record or variant of a type the program wrote a `Display` impl for is diff --git a/src/vm/tests.rs b/src/vm/tests.rs index a9585f094..1650a05cb 100644 --- a/src/vm/tests.rs +++ b/src/vm/tests.rs @@ -2315,7 +2315,7 @@ fn test_custom_display_trait() { } fn main() { let s = Circle(5.0) - s.display() + "{s}" } "#, ); @@ -3403,13 +3403,13 @@ trait Step for C { fn go(self, k: Int) -> Int { match k { 0 -> 1 / k - _ -> self.go(k - 1) + _ -> Step.go(self, k - 1) } } } fn main() { let c = C { n: 1 } - println(c.go(5)) + println(Step.go(c, 5)) } "; assert_eq!( @@ -4406,6 +4406,7 @@ mod type_confusion { method: 0, argc: 1, of: 0, + at: 0, }, span(), ) @@ -6148,10 +6149,20 @@ mod methods_in_place { } fn call(argc: u8, tail: bool) -> Asm<'static> { - let (method, argc, of) = (0, usize::from(argc), 0); + let (method, argc, of, at) = (0, usize::from(argc), 0, 0); match tail { - true => Asm::TailCallMethod { method, argc, of }, - false => Asm::CallMethod { method, argc, of }, + true => Asm::TailCallMethod { + method, + argc, + of, + at, + }, + false => Asm::CallMethod { + method, + argc, + of, + at, + }, } } diff --git a/tests/cli/stage7_io_timeout_tests.rs b/tests/cli/stage7_io_timeout_tests.rs index 1091f0196..93db08160 100644 --- a/tests/cli/stage7_io_timeout_tests.rs +++ b/tests/cli/stage7_io_timeout_tests.rs @@ -63,7 +63,7 @@ fn main() { match tcp.accept(listener) { Err(tcp.Timeout) -> println("timed out") Ok(_) -> println("a connection") - Err(e) -> println("another error: {e.message()}") + Err(e) -> println("another error: {Error.message(e)}") } } } @@ -125,7 +125,7 @@ fn main() { } match tcp.read(peer, 10) { Ok(got) -> println("the peer read {bytes.length(got)} bytes: the end") - Err(e) -> println("the peer: {e.message()}") + Err(e) -> println("the peer: {Error.message(e)}") } } "#; @@ -157,7 +157,7 @@ fn main() { match stream.write_to_tcp(chunks, client) { Err(tcp.Timeout) -> println("the write timed out") Ok(_) -> println("all was written") - Err(e) -> println("the write: {e.message()}") + Err(e) -> println("the write: {Error.message(e)}") } } "#; diff --git a/tests/cli/trait_init_parity_tests.rs b/tests/cli/trait_init_parity_tests.rs index 1ac1a10c6..e297b35d3 100644 --- a/tests/cli/trait_init_parity_tests.rs +++ b/tests/cli/trait_init_parity_tests.rs @@ -13,7 +13,7 @@ fn trait_impls_cover_every_builtin_trait_name() { // on at least one primitive. If a future edit removes all auto-derived // registrations for a trait, this catches it before downstream // diagnostics get mysterious. - let (impls, _) = __trait_init_fingerprint_check_program(); + let impls = __trait_init_fingerprint_check_program(); for trait_name in ["Equal", "Compare", "Hash", "Display"] { let has_some = impls .iter() @@ -30,7 +30,7 @@ fn primitives_get_all_four_traits() { // Lock the derive policy: every primitive should have all four // built-in traits registered. If policy shifts, this test makes // the change visible. - let (impls, _) = __trait_init_fingerprint_check_program(); + let impls = __trait_init_fingerprint_check_program(); // Round 75 TYPE-3 flipped the Unit canonical direction from // `Unit → ()` to `() → Unit`, aligning with the VM dispatch // oracle. The trait_impl_set keys now use "Unit" not "()". @@ -54,7 +54,7 @@ fn non_ordering_container_types_lack_compare() { // Map and Set have no order. Option and Result have no `compare` // method entry (they are ordered by their structure, like any enum). // A tuple is ordered part by part and has Compare. - let (impls, _) = __trait_init_fingerprint_check_program(); + let impls = __trait_init_fingerprint_check_program(); assert!(impls.contains("Compare:Tuple")); for type_name in ["Map", "Set", "Option", "Result"] { let key = format!("Compare:{type_name}"); diff --git a/tests/concurrency/io_timeout_watchdog_tests.rs b/tests/concurrency/io_timeout_watchdog_tests.rs index e0e9975c3..2f4923f27 100644 --- a/tests/concurrency/io_timeout_watchdog_tests.rs +++ b/tests/concurrency/io_timeout_watchdog_tests.rs @@ -124,7 +124,7 @@ fn main() { let handle = task.spawn({ -> match io.read_line() { Ok(_) -> "unexpected_ok" - Err(e) -> e.message() + Err(e) -> Error.message(e) } }) println(task.join(handle)) @@ -220,12 +220,12 @@ fn main() {{ match tcp.read(s, 1024) {{ Ok(_) -> "unexpected-ok" Err(tcp.Timeout) -> "tcp-timeout" - Err(other) -> "other:{{other.message()}}" + Err(other) -> "other:{{Error.message(other)}}" }} }}) println(task.join(outcome)) }} - Err(e) -> println("connect-err:{{e.message()}}") + Err(e) -> println("connect-err:{{Error.message(e)}}") }} }} "# diff --git a/tests/concurrency/repl_tasks_see_later_entries_tests.rs b/tests/concurrency/repl_tasks_see_later_entries_tests.rs index cf3ec46f0..ed9383125 100644 --- a/tests/concurrency/repl_tasks_see_later_entries_tests.rs +++ b/tests/concurrency/repl_tasks_see_later_entries_tests.rs @@ -210,7 +210,7 @@ fn a_task_calls_a_method_of_an_impl_of_a_later_entry() { assert_tasks_see( "trait N { fn n(self) -> String }", "trait N for Int { fn n(self) -> String { \"int\" } }", - "5.n()", + "N.n(5)", "int", ); } @@ -222,7 +222,7 @@ fn a_task_calls_a_method_of_an_impl_of_a_later_entry() { #[test] fn a_task_finds_an_impl_of_a_later_entry_through_an_earlier_generic_function() { assert_tasks_see( - "trait N { fn n(self) -> String }\nfn call(v: a) -> String where a: N { v.n() }", + "trait N { fn n(self) -> String }\nfn call(v: a) -> String where a: N { N.n(v) }", "type Q { q: Int }\n\ trait N for Int { fn n(self) -> String { \"int\" } }\n\ trait N for Q { fn n(self) -> String { \"q{self.q}\" } }", @@ -232,12 +232,12 @@ fn a_task_finds_an_impl_of_a_later_entry_through_an_earlier_generic_function() { } /// A `Display` impl of a later entry is used wherever the value is -/// shown: in an interpolation and by `.display()`, inside a list. It +/// shown: in an interpolation and by `string.from`, inside a list. It /// was not used, and nothing said so: `[Q {q: 2}]|[Q {q: 2}]`. #[test] fn a_task_shows_a_value_with_the_display_impl_of_a_later_entry() { assert_tasks_see( - "fn sh(v: a) -> String where a: Display { \"{v}|{v.display()}\" }", + "import string\nfn sh(v: a) -> String where a: Display { \"{v}|{string.from(v)}\" }", "type Q { q: Int }\ntrait Display for Q { fn display(self) -> String { \"Q!\" } }", "sh([Q { q: 2 }])", "[Q!]|[Q!]", @@ -279,7 +279,7 @@ fn a_task_calls_a_method_of_a_trait_of_a_later_entry() { assert_tasks_see( "", "trait M { fn m(self) -> String }\ntrait M for Int { fn m(self) -> String { \"m{self}\" } }", - "{\n let call = { y -> y.m() }\n call(7)\n}", + "{\n let call = { y -> M.m(y) }\n call(7)\n}", "m7", ); } @@ -307,7 +307,7 @@ fn a_task_decodes_into_record_types_of_a_later_entry() { fn the_function_of_a_deadline_sees_later_entries_in_a_task_of_an_earlier_one() { assert_tasks_see( "import time\ntrait N { fn n(self) -> String }\n\ - fn call(v: a) -> String where a: N { v.n() }", + fn call(v: a) -> String where a: N { N.n(v) }", "fn later() -> String { \"fn\" }\n\ trait N for Int { fn n(self) -> String { \"int\" } }\n\ type Q { q: Int }\n\ @@ -341,7 +341,7 @@ fn burn(n) {{ }} }} trait N {{ fn n(self) -> String }} -fn call(v: a) -> String where a: N {{ v.n() }} +fn call(v: a) -> String where a: N {{ N.n(v) }} fn work(left) {{ match left {{ 0 -> () @@ -546,11 +546,11 @@ fn work(left) { } } let worker = task.spawn { -> work(2) } -channel.send(jobs, { -> 5.n() }) +channel.send(jobs, { -> N.n(5) }) channel.receive(outs) trait N for Int { fn n(self) -> String { \"second\" } } -5.n() -channel.send(jobs, { -> 5.n() }) +N.n(5) +channel.send(jobs, { -> N.n(5) }) channel.receive(outs) task.join(worker) ", @@ -755,7 +755,7 @@ fn a_session_sets_no_slot_twice() { for entry in [ "import task\nimport channel\nimport io", "let jobs = channel.new(8)\nlet outs = channel.new(8)", - "trait N { fn n(self) -> String }\nfn call(v: a) -> String where a: N { v.n() }", + "trait N { fn n(self) -> String }\nfn call(v: a) -> String where a: N { N.n(v) }", "fn work() {\n match channel.receive(jobs) {\n Some(job) -> {\n \ channel.send(outs, job())\n work()\n }\n None -> ()\n }\n}", "let worker = task.spawn { -> work() }", @@ -767,21 +767,21 @@ fn a_session_sets_no_slot_twice() { assert_eq!( run("let stamp = \"one\"\n\ trait N for Int { fn n(self) -> String { \"first {stamp}\" } }\n\ - let sent = channel.send(jobs, { -> \"{stamp} {5.n()} {call(5)}\" })\n\ + let sent = channel.send(jobs, { -> \"{stamp} {N.n(5)} {call(5)}\" })\n\ let got = channel.receive(outs)\n\ let boom = 1 / 0"), failed("division by zero") ); // The impl is gone with the entry, for the session and for the task. - assert!(run("5.n()").is_err()); + assert!(run("N.n(5)").is_err()); // It is written again, and differently. assert_eq!( run("trait N for Int { fn n(self) -> String { \"second\" } }"), ok("()") ); - assert_eq!(run("\"{5.n()} {call(5)}\""), ok("second second")); + assert_eq!(run("\"{N.n(5)} {call(5)}\""), ok("second second")); assert_eq!( - run("channel.send(jobs, { -> \"{5.n()} {call(5)}\" })"), + run("channel.send(jobs, { -> \"{N.n(5)} {call(5)}\" })"), ok("()") ); assert_eq!(run("channel.receive(outs)"), ok("Some(second second)")); @@ -799,7 +799,7 @@ fn a_session_sets_no_slot_twice() { assert_eq!(run("channel.receive(outs)"), ok("Some(two tag-two)")); for entry in [ "let stamp = \"again\"", - "fn call(v: a) -> String where a: N { \"again {v.n()}\" }", + "fn call(v: a) -> String where a: N { \"again {N.n(v)}\" }", "type Q { q: Int }", "trait N for Q { fn n(self) -> String { \"q\" } }", "type Q { r: Int }", diff --git a/tests/database/a_channel_is_notified_under_the_name_it_was_listened_on.silt b/tests/database/a_channel_is_notified_under_the_name_it_was_listened_on.silt index 6b37454ea..959d32c38 100644 --- a/tests/database/a_channel_is_notified_under_the_name_it_was_listened_on.silt +++ b/tests/database/a_channel_is_notified_under_the_name_it_was_listened_on.silt @@ -31,14 +31,14 @@ fn round_trip(db: postgres.PgPool, name: String) { match got { Ok(Some(n)) -> println("{name}: got {n.payload} on {n.channel}") Ok(None) -> println("{name}: the listener ended") - Err(e) -> println("{name}: nothing came ({e.message()})") + Err(e) -> println("{name}: nothing came ({Error.message(e)})") } } - Err(e) -> println("notify {name}: {e.message()}") + Err(e) -> println("notify {name}: {Error.message(e)}") } channel.close(ch) } - Err(e) -> println("listen {name}: {e.message()}") + Err(e) -> println("listen {name}: {Error.message(e)}") } } @@ -49,11 +49,11 @@ fn refused(db: postgres.PgPool, name: String) { println("listen took it") channel.close(ch) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match postgres.notify(db, name, "x") { Ok(_) -> println("notify took it") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } @@ -76,6 +76,6 @@ fn main() { } postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_connect_nobody_waits_for_leaves_no_session.silt b/tests/database/a_connect_nobody_waits_for_leaves_no_session.silt index 33202883a..45c7f428f 100644 --- a/tests/database/a_connect_nobody_waits_for_leaves_no_session.silt +++ b/tests/database/a_connect_nobody_waits_for_leaves_no_session.silt @@ -34,7 +34,7 @@ fn sessions(db: postgres.PgPool) -> String { let sql = "SELECT count(*)::int AS n FROM pg_stat_activity WHERE application_name = 'silt_given_up_connect'" match postgres.query(db, sql, (), json.Value) { Ok(rows) -> "{rows}" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } @@ -47,7 +47,7 @@ fn main() { match got { -- In time: the program closes the pool itself. Ok(Ok(other)) -> postgres.close(other) - Ok(Err(e)) -> println("connect: {e.message()}") + Ok(Err(e)) -> println("connect: {Error.message(e)}") Err(_) -> () } } @@ -57,6 +57,6 @@ fn main() { println("after: {sessions(db)}") postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_connection_the_server_ended_is_not_taken.silt b/tests/database/a_connection_the_server_ended_is_not_taken.silt index 7f35e667c..cedb1588f 100644 --- a/tests/database/a_connection_the_server_ended_is_not_taken.silt +++ b/tests/database/a_connection_the_server_ended_is_not_taken.silt @@ -50,7 +50,7 @@ fn round(db: postgres.PgPool, observer: postgres.PgPool) -> Result(String, postg match postgres.query(db, "SELECT pg_backend_pid()::int8 AS pid", (), Pid) { Ok([row]) when row.pid != pid -> Ok("a new connection") Ok(_) -> Ok("the same connection") - Err(e) -> Ok("the statement failed: {e.message()}") + Err(e) -> Ok("the statement failed: {Error.message(e)}") } } @@ -60,7 +60,7 @@ fn main() { let answers = 1..20 |> list.map { _ -> match round(db, observer) { Ok(answer) -> answer - Err(e) -> "the round failed: {e.message()}" + Err(e) -> "the round failed: {Error.message(e)}" } } let other = answers |> list.filter { a -> a != "a new connection" } diff --git a/tests/database/a_cursor_ends_at_a_batch_that_fails.silt b/tests/database/a_cursor_ends_at_a_batch_that_fails.silt index 4645d1439..eacf2d686 100644 --- a/tests/database/a_cursor_ends_at_a_batch_that_fails.silt +++ b/tests/database/a_cursor_ends_at_a_batch_that_fails.silt @@ -32,6 +32,6 @@ fn main() { println("transact: {done}") postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_field_is_decoded_by_its_json_decode_impl.silt b/tests/database/a_field_is_decoded_by_its_json_decode_impl.silt index 6b1c8b69f..4e0e4c156 100644 --- a/tests/database/a_field_is_decoded_by_its_json_decode_impl.silt +++ b/tests/database/a_field_is_decoded_by_its_json_decode_impl.silt @@ -73,7 +73,7 @@ FROM generate_series(1, 2) g Ok(db) -> { match postgres.query(db, sql, (), Row) { Ok(rows) -> list.each(rows) { r -> println(r) } - Err(e) -> println("query: {e.message()}") + Err(e) -> println("query: {Error.message(e)}") } let read = postgres.transact(db) { tx -> let c = postgres.cursor(tx, sql, (), 1, Row)? @@ -85,10 +85,10 @@ FROM generate_series(1, 2) g println("a cursor: {read}") match postgres.stream(db, sql, (), Row) { Ok(rows) -> channel.each(rows) { r -> println("a stream: {r}") } - Err(e) -> println("a stream: {e.message()}") + Err(e) -> println("a stream: {Error.message(e)}") } postgres.close(db) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/database/a_listen_nobody_waits_for_gives_its_connection_back.silt b/tests/database/a_listen_nobody_waits_for_gives_its_connection_back.silt index 7b3770a21..170123c0a 100644 --- a/tests/database/a_listen_nobody_waits_for_gives_its_connection_back.silt +++ b/tests/database/a_listen_nobody_waits_for_gives_its_connection_back.silt @@ -29,16 +29,16 @@ fn main() { match got { -- In time: the program closes its listener itself. Ok(Ok(ch)) -> channel.close(ch) - Ok(Err(e)) -> println("listen: {e.message()}") + Ok(Err(e)) -> println("listen: {Error.message(e)}") Err(_) -> () } } match postgres.query(db, "SELECT 1 AS n", (), json.Value) { Ok(rows) -> println("the pool serves: {list.length(rows)} row") - Err(e) -> println("query: {e.message()}") + Err(e) -> println("query: {Error.message(e)}") } postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_parameter_is_written_as_its_json_encode_impl_says.silt b/tests/database/a_parameter_is_written_as_its_json_encode_impl_says.silt index 697693598..7be22c129 100644 --- a/tests/database/a_parameter_is_written_as_its_json_encode_impl_says.silt +++ b/tests/database/a_parameter_is_written_as_its_json_encode_impl_says.silt @@ -40,7 +40,7 @@ fn main() { println(postgres.execute(db, "SELECT $1::jsonb", (m,))) match postgres.stream(db, "SELECT $1::jsonb::text AS v", ((m, "a"),), Out) { Ok(rows) -> println("a stream: {channel.receive(rows)}") - Err(e) -> println("a stream: {e.message()}") + Err(e) -> println("a stream: {Error.message(e)}") } let read = postgres.transact(db) { tx -> let c = postgres.cursor(tx, "SELECT $1::jsonb::text AS v", (#{"price": m},), 2, Out)? @@ -50,6 +50,6 @@ fn main() { } println("a cursor: {read}") } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/database/a_parameter_that_cannot_be_sent.silt b/tests/database/a_parameter_that_cannot_be_sent.silt index 9a067e85c..f5981190f 100644 --- a/tests/database/a_parameter_that_cannot_be_sent.silt +++ b/tests/database/a_parameter_that_cannot_be_sent.silt @@ -25,24 +25,24 @@ fn main() { Ok(db) -> { match postgres.query(db, "SELECT cardinality($1::bytea[])::text AS v", ([pic, pic],), Out) { Ok(rows) -> println("into a bytea[]: {rows}") - Err(e) -> println("into a bytea[]: {e.message()}") + Err(e) -> println("into a bytea[]: {Error.message(e)}") } match postgres.stream(db, "SELECT $1::jsonb::text AS v", ([pic],), Out) { Ok(rows) -> { match channel.receive(rows) { Some(Ok(row)) -> println("a stream into jsonb: {row}") Some(Err(postgres.Other(why))) -> println("a stream into jsonb: Other({why})") - Some(Err(e)) -> println("a stream into jsonb: {e.message()}") + Some(Err(e)) -> println("a stream into jsonb: {Error.message(e)}") None -> println("a stream into jsonb: closed") } println("then: {channel.receive(rows)}") } - Err(e) -> println("a stream into jsonb: {e.message()}") + Err(e) -> println("a stream into jsonb: {Error.message(e)}") } println("a query into jsonb:") let _ = postgres.query(db, "SELECT $1::jsonb::text AS v", ([pic],), Out) println("not reached") } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_pool_opens_connections_when_it_needs_them.silt b/tests/database/a_pool_opens_connections_when_it_needs_them.silt index a9d1cc7c7..d81ca32a7 100644 --- a/tests/database/a_pool_opens_connections_when_it_needs_them.silt +++ b/tests/database/a_pool_opens_connections_when_it_needs_them.silt @@ -32,7 +32,7 @@ fn sessions(db: postgres.PgPool) -> String { match postgres.query(db, sql, (), N) { Ok([row]) -> "{row.n}" Ok(rows) -> "{rows}" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } @@ -50,12 +50,12 @@ fn main() { sleepers |> list.each { t -> match task.join(t) { Ok(_) -> () - Err(e) -> println("a statement at once: {e.message()}") + Err(e) -> println("a statement at once: {Error.message(e)}") } } println("after two statements at once: {sessions(db)}") postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_pool_statement_without_its_connection_is_not_sent.silt b/tests/database/a_pool_statement_without_its_connection_is_not_sent.silt index 6a38e23b9..2e026c711 100644 --- a/tests/database/a_pool_statement_without_its_connection_is_not_sent.silt +++ b/tests/database/a_pool_statement_without_its_connection_is_not_sent.silt @@ -29,7 +29,7 @@ fn main() { println( match late { Ok(_) -> "the insert came back" - Err(e) -> "task.deadline: {e.message()}" + Err(e) -> "task.deadline: {Error.message(e)}" }, ) Ok(()) @@ -37,16 +37,16 @@ fn main() { println( match done { Ok(_) -> "main's transaction: Ok" - Err(e) -> "main's transaction: {e.message()}" + Err(e) -> "main's transaction: {Error.message(e)}" }, ) time.sleep(time.ms(300)) match postgres.query(pool, "SELECT count(*)::int AS n FROM silt_late_statement", (), json.Value) { Ok(rows) -> println("rows: {rows}") - Err(e) -> println("count: {e.message()}") + Err(e) -> println("count: {Error.message(e)}") } postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_record_in_a_field_decodes_an_enum_by_json_s_rules.silt b/tests/database/a_record_in_a_field_decodes_an_enum_by_json_s_rules.silt index 46b9275f4..d39e4ed45 100644 --- a/tests/database/a_record_in_a_field_decodes_an_enum_by_json_s_rules.silt +++ b/tests/database/a_record_in_a_field_decodes_an_enum_by_json_s_rules.silt @@ -28,7 +28,7 @@ fn url() -> String { fn show(r: Result(List(a), postgres.PostgresError)) where a: Display { match r { Ok(rows) -> println(rows) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } @@ -43,6 +43,6 @@ fn main() { show(postgres.query(db, "SELECT json_build_object('state', $1::jsonb) AS inner", (Paused(4),), Wrapped)) postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_row_type_with_an_impl_is_decoded_by_it.silt b/tests/database/a_row_type_with_an_impl_is_decoded_by_it.silt index 5f346be8b..66bdee05d 100644 --- a/tests/database/a_row_type_with_an_impl_is_decoded_by_it.silt +++ b/tests/database/a_row_type_with_an_impl_is_decoded_by_it.silt @@ -54,11 +54,11 @@ fn main() { println(postgres.query(db, "SELECT g AS n FROM generate_series(1, 2) g", (), Size)) match postgres.query(db, "SELECT 'x' AS n", (), Size) { Ok(rows) -> println(rows) - Err(e) -> println("Err: {e.message()}") + Err(e) -> println("Err: {Error.message(e)}") } match postgres.query(db, "SELECT 1 AS m", (), Size) { Ok(rows) -> println(rows) - Err(e) -> println("Err: {e.message()}") + Err(e) -> println("Err: {Error.message(e)}") } let read = postgres.transact(db) { tx -> let c = postgres.cursor(tx, "SELECT g AS n FROM generate_series(1, 3) g", (), 2, Size)? @@ -69,6 +69,6 @@ fn main() { println("a cursor: {read}") postgres.close(db) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/database/a_statement_behind_its_own_unread_stream_fails.silt b/tests/database/a_statement_behind_its_own_unread_stream_fails.silt index 796b74553..d2b5507f5 100644 --- a/tests/database/a_statement_behind_its_own_unread_stream_fails.silt +++ b/tests/database/a_statement_behind_its_own_unread_stream_fails.silt @@ -27,11 +27,11 @@ fn main() { match postgres.query(tx, "SELECT 1::int8 AS n", (), N) { Ok(found) -> println("the statement ran: {found}") Err(postgres.Other(text)) -> println("the statement: Other({text})") - Err(e) -> println("the statement: {e.message()}") + Err(e) -> println("the statement: {Error.message(e)}") } match postgres.execute(tx, "SELECT 1", ()) { Ok(n) -> println("execute ran: {n}") - Err(e) -> println("execute: {e.message()}") + Err(e) -> println("execute: {Error.message(e)}") } channel.close(rows) postgres.query(tx, "SELECT 2::int8 AS n", (), N) @@ -39,6 +39,6 @@ fn main() { println("transact: {done}") postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_statement_behind_its_own_unread_stream_of_impls_fails.silt b/tests/database/a_statement_behind_its_own_unread_stream_of_impls_fails.silt index 9b2968a2f..9f4cf6f5b 100644 --- a/tests/database/a_statement_behind_its_own_unread_stream_of_impls_fails.silt +++ b/tests/database/a_statement_behind_its_own_unread_stream_of_impls_fails.silt @@ -44,11 +44,11 @@ fn main() { match postgres.query(tx, "SELECT 1::int8 AS n", (), N) { Ok(found) -> println("the statement ran: {found}") Err(postgres.Other(text)) -> println("the statement: Other({text})") - Err(e) -> println("the statement: {e.message()}") + Err(e) -> println("the statement: {Error.message(e)}") } match postgres.execute(tx, "SELECT 1", ()) { Ok(n) -> println("execute ran: {n}") - Err(e) -> println("execute: {e.message()}") + Err(e) -> println("execute: {Error.message(e)}") } channel.close(rows) postgres.query(tx, "SELECT 2::int8 AS n", (), N) @@ -56,6 +56,6 @@ fn main() { println("transact: {done}") postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_statement_right_after_the_server_ends_its_sessions_runs.silt b/tests/database/a_statement_right_after_the_server_ends_its_sessions_runs.silt index 613307f8a..5367702b7 100644 --- a/tests/database/a_statement_right_after_the_server_ends_its_sessions_runs.silt +++ b/tests/database/a_statement_right_after_the_server_ends_its_sessions_runs.silt @@ -62,7 +62,7 @@ fn rounds(db: postgres.PgPool, observer: postgres.PgPool, then: Fn() -> ()) -> L then() match postgres.query(db, "SELECT 1::int8 AS n", (), N) { Ok(_) -> "ok" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } |> list.filter { answer -> answer != "ok" } diff --git a/tests/database/a_statement_that_never_got_the_connection_gives_up.silt b/tests/database/a_statement_that_never_got_the_connection_gives_up.silt index 3d8fa55cc..674b694ac 100644 --- a/tests/database/a_statement_that_never_got_the_connection_gives_up.silt +++ b/tests/database/a_statement_that_never_got_the_connection_gives_up.silt @@ -31,17 +31,17 @@ fn main() { let late = task.deadline(time.ms(200)) { -> postgres.query(tx, "SELECT 1::int8 AS n", (), N) } match late { Ok(answer) -> println("the waiting statement answered: {answer}") - Err(e) -> println("the waiting statement: {e.message()}") + Err(e) -> println("the waiting statement: {Error.message(e)}") } match task.join(sleeper) { Ok(_) -> println("the running statement: Ok") - Err(e) -> println("the running statement: {e.message()}") + Err(e) -> println("the running statement: {Error.message(e)}") } postgres.query(tx, "SELECT 2::int8 AS n", (), N) } println("transact: {done}") postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/a_stream_ends_at_an_impls_error.silt b/tests/database/a_stream_ends_at_an_impls_error.silt index 4a2a7d214..a876fba83 100644 --- a/tests/database/a_stream_ends_at_an_impls_error.silt +++ b/tests/database/a_stream_ends_at_an_impls_error.silt @@ -52,12 +52,12 @@ fn main() { println("an Err:") match postgres.stream(db, string.replace(sql, ":k", "7"), (), R) { Ok(rows) -> drain(rows) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println("a failure:") match postgres.stream(db, string.replace(sql, ":k", "0"), (), R) { Ok(rows) -> drain(rows) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println("closed:") match postgres.stream(db, "SELECT g AS n, to_jsonb(g::text) AS code FROM generate_series(1, 100000) g", (), R) { @@ -66,10 +66,10 @@ fn main() { channel.close(rows) println(" closed") } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } postgres.close(db) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/database/a_stream_whose_impl_waits_forever_is_a_deadlock.silt b/tests/database/a_stream_whose_impl_waits_forever_is_a_deadlock.silt index 6b08c70d1..23b71e248 100644 --- a/tests/database/a_stream_whose_impl_waits_forever_is_a_deadlock.silt +++ b/tests/database/a_stream_whose_impl_waits_forever_is_a_deadlock.silt @@ -36,9 +36,9 @@ fn main() { Ok(db) -> { match postgres.stream(db, "SELECT to_jsonb(g) AS stuck FROM generate_series(1, 3) g", (), S) { Ok(rows) -> println("first: {channel.receive(rows)}") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/database/a_stream_with_impls_ends_with_its_reader.silt b/tests/database/a_stream_with_impls_ends_with_its_reader.silt index 63b6d2976..fa69e6666 100644 --- a/tests/database/a_stream_with_impls_ends_with_its_reader.silt +++ b/tests/database/a_stream_with_impls_ends_with_its_reader.silt @@ -37,7 +37,7 @@ fn url() -> String { fn first(rows: Channel(Result(R, postgres.PostgresError))) -> String { match channel.receive(rows) { Some(Ok(row)) -> "the first row: {row}" - Some(Err(e)) -> e.message() + Some(Err(e)) -> Error.message(e) None -> "no row" } } @@ -55,16 +55,16 @@ fn main() { let _ = channel.receive(never) "the function ended" } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } match late { Ok(said) -> println(said) - Err(e) -> println("task.deadline: {e.message()}") + Err(e) -> println("task.deadline: {Error.message(e)}") } match postgres.query(pool, "SELECT 1 AS n, to_jsonb('1'::text) AS code", (), R) { Ok(rows) -> println("the next statement: {rows}") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } let got: Channel(String) = channel.new(1) let reader = task.spawn { -> @@ -75,7 +75,7 @@ fn main() { let _ = channel.receive(never) () } - Err(e) -> channel.send(got, e.message()) + Err(e) -> channel.send(got, Error.message(e)) } } match channel.receive(got) { @@ -85,6 +85,6 @@ fn main() { task.cancel(reader) println("the reader is cancelled, main returns") } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/database/a_stream_with_impls_keeps_its_rows_errors_and_end.silt b/tests/database/a_stream_with_impls_keeps_its_rows_errors_and_end.silt index e3f603026..5924ca504 100644 --- a/tests/database/a_stream_with_impls_keeps_its_rows_errors_and_end.silt +++ b/tests/database/a_stream_with_impls_keeps_its_rows_errors_and_end.silt @@ -75,7 +75,7 @@ fn drain(rows: Channel(Result(R, postgres.PostgresError))) { true -> loop(n + 1) false -> (n, "row {n + 1} is out of order: {row}") } - Some(Err(e)) -> (n, "Err({e.message()})") + Some(Err(e)) -> (n, "Err({Error.message(e)})") None -> (n, "(end)") } } @@ -93,7 +93,7 @@ fn stream(db: postgres.PgPool, n: String, code: String) { let sql = string.replace(string.replace(sql, ":n", n), ":code", code) match postgres.stream(db, sql, (), R) { Ok(rows) -> drain(rows) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } @@ -123,17 +123,17 @@ fn main() { channel.close(rows) println(" {n} rows, closed") } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match postgres.query(db, "SELECT 1 AS n, to_jsonb('1'::text) AS code", (), R) { Ok(rows) -> println(" the next statement: {rows}") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println("in a transaction:") let done = postgres.transact(db) { tx -> match postgres.stream(tx, "SELECT g AS n, CASE WHEN g % 3 = 0 THEN NULL ELSE to_jsonb(g::text) END AS code FROM generate_series(1, 2000) g", (), R) { Ok(rows) -> drain(rows) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } Ok(()) } @@ -145,7 +145,7 @@ fn main() { match channel.receive(rows) { Some(Ok(row)) -> loop(n + 1, sum + row.slow.n) Some(Err(e)) -> { - println(e.message()) + println(Error.message(e)) (n, sum) } None -> (n, sum) @@ -153,10 +153,10 @@ fn main() { } println(" {n} rows, their sum {sum}") } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } postgres.close(db) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/database/a_stream_with_impls_sends_each_row_when_it_is_finished.silt b/tests/database/a_stream_with_impls_sends_each_row_when_it_is_finished.silt index 23091cf11..bc3b257a2 100644 --- a/tests/database/a_stream_with_impls_sends_each_row_when_it_is_finished.silt +++ b/tests/database/a_stream_with_impls_sends_each_row_when_it_is_finished.silt @@ -120,7 +120,7 @@ fn main() { println(" {first}") channel.close(rows) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println("an impl that waits for the reader:") match postgres.stream(db, "SELECT to_jsonb(g) AS step FROM generate_series(1, 5) g", (), T) { @@ -131,11 +131,11 @@ fn main() { println(" read {r.step.n}") let _ = io.write_file(marker(r.step.n), "") } - Err(e) -> println(" Err {e.message()}") + Err(e) -> println(" Err {Error.message(e)}") } } } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } loop n = 1 { match n <= 5 { @@ -153,7 +153,7 @@ fn main() { println(" {first}") channel.close(rows) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println(" the next statement: {postgres.query(db, "SELECT 1 AS n", (), One)}") println("an impl that calls env.set:") @@ -163,7 +163,7 @@ fn main() { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println(" Err {e.message()}") + println(" Err {Error.message(e)}") n } None -> n @@ -171,11 +171,11 @@ fn main() { } println(" {n} rows") } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println(" F8P_SEEN: {env.get("F8P_SEEN")}") postgres.close(db) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/database/aborted_transaction_is_not_committed.silt b/tests/database/aborted_transaction_is_not_committed.silt index 46dbaa7e3..ea515f00e 100644 --- a/tests/database/aborted_transaction_is_not_committed.silt +++ b/tests/database/aborted_transaction_is_not_committed.silt @@ -23,14 +23,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -39,7 +39,7 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { fn said(answer: Result(a, postgres.PostgresError)) -> String { match answer { Ok(_) -> "Ok" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } @@ -71,6 +71,6 @@ fn main() { let _ = postgres.execute(pool, "DROP TABLE silt_database_aborted", ()) postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/an_impl_error_in_a_field_is_the_columns_type_mismatch.silt b/tests/database/an_impl_error_in_a_field_is_the_columns_type_mismatch.silt index a737e5ce9..19f078f38 100644 --- a/tests/database/an_impl_error_in_a_field_is_the_columns_type_mismatch.silt +++ b/tests/database/an_impl_error_in_a_field_is_the_columns_type_mismatch.silt @@ -38,7 +38,7 @@ fn url() -> String { fn show(r: Result(a, postgres.PostgresError)) -> String where a: Display { match r { Ok(v) -> "Ok({v})" - Err(e) -> "Err({e.message()})" + Err(e) -> "Err({Error.message(e)})" } } @@ -65,6 +65,6 @@ fn main() { println("transact: {read}") postgres.close(db) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/database/bytes_as_a_field_or_in_a_list_is_read.silt b/tests/database/bytes_as_a_field_or_in_a_list_is_read.silt index 4faf3cbdc..9017326d7 100644 --- a/tests/database/bytes_as_a_field_or_in_a_list_is_read.silt +++ b/tests/database/bytes_as_a_field_or_in_a_list_is_read.silt @@ -20,7 +20,7 @@ fn rows(db: postgres.PgPool, sql: String, type a) -> Result(List(a), postgres.Po fn show(r: Result(List(a), postgres.PostgresError)) { match r { Ok(rows) -> println("{list.length(rows)} rows") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } @@ -30,6 +30,6 @@ fn main() { show(rows(db, "SELECT '\\x00ff'::bytea AS b, ARRAY['\\x01'::bytea] AS bs", Plain)) postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/callback_deadline_aborts_its_transaction.silt b/tests/database/callback_deadline_aborts_its_transaction.silt index 7bd29c042..fe90385a6 100644 --- a/tests/database/callback_deadline_aborts_its_transaction.silt +++ b/tests/database/callback_deadline_aborts_its_transaction.silt @@ -32,14 +32,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -48,7 +48,7 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { fn said(answer: Result(a, postgres.PostgresError)) -> String { match answer { Ok(_) -> "Ok" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } @@ -79,7 +79,7 @@ fn main() { println( match late { Ok(answer) -> "the statement: {said(answer)}" - Err(e) -> "task.deadline: {e.message()}" + Err(e) -> "task.deadline: {Error.message(e)}" }, ) println("the next statement: {said(postgres.execute(tx, "SELECT 1", ()))}") @@ -116,6 +116,6 @@ fn main() { let _ = postgres.execute(pool, "DROP TABLE silt_database_callback_deadline", ()) postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/cancel_of_a_statement_in_a_transaction.silt b/tests/database/cancel_of_a_statement_in_a_transaction.silt index a981785e7..8988cbace 100644 --- a/tests/database/cancel_of_a_statement_in_a_transaction.silt +++ b/tests/database/cancel_of_a_statement_in_a_transaction.silt @@ -31,14 +31,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -86,7 +86,7 @@ fn main() { } match ended { Ok(said) -> println("the task went on with {said}") - Err(e) -> println("the task went on with {e.message()}") + Err(e) -> println("the task went on with {Error.message(e)}") } } println("statements that wait for it in the server: {until(pool, waiting(), 1)}") @@ -102,6 +102,6 @@ fn main() { let _ = postgres.execute(pool, "DROP TABLE silt_database_cancel_tx", ()) postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/cancel_of_a_statement_in_flight.silt b/tests/database/cancel_of_a_statement_in_flight.silt index 12f5cbc4e..24d3a197e 100644 --- a/tests/database/cancel_of_a_statement_in_flight.silt +++ b/tests/database/cancel_of_a_statement_in_flight.silt @@ -32,14 +32,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -93,6 +93,6 @@ fn main() { let _ = postgres.execute(pool, "DROP TABLE silt_database_cancel", ()) postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/cancel_request_reaches_no_other_statement.silt b/tests/database/cancel_request_reaches_no_other_statement.silt index 5c6bf8884..de62b6244 100644 --- a/tests/database/cancel_request_reaches_no_other_statement.silt +++ b/tests/database/cancel_request_reaches_no_other_statement.silt @@ -49,6 +49,6 @@ fn main() { println("rounds in which main's statement failed: {failed}") postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/cancelled_task_starts_no_statement.silt b/tests/database/cancelled_task_starts_no_statement.silt index 3d2746b46..f10f883b3 100644 --- a/tests/database/cancelled_task_starts_no_statement.silt +++ b/tests/database/cancelled_task_starts_no_statement.silt @@ -36,14 +36,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -77,7 +77,7 @@ fn main() { json.Value, ) { Ok(rows) -> channel.send(streams, rows) - Err(e) -> println("postgres.stream: {e.message()}") + Err(e) -> println("postgres.stream: {Error.message(e)}") } let _ = postgres.execute( pool, @@ -108,6 +108,6 @@ fn main() { let _ = postgres.execute(pool, "DROP TABLE silt_database_cancelled", ()) postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/channel_each_raises_the_failure_of_a_streams_impl.silt b/tests/database/channel_each_raises_the_failure_of_a_streams_impl.silt index 2747f7f43..a74e8c591 100644 --- a/tests/database/channel_each_raises_the_failure_of_a_streams_impl.silt +++ b/tests/database/channel_each_raises_the_failure_of_a_streams_impl.silt @@ -33,10 +33,10 @@ fn main() { let sql = "SELECT to_jsonb(3 - g) AS code FROM generate_series(1, 4) g" match postgres.stream(db, sql, (), R) { Ok(rows) -> channel.each(rows) { row -> println(row) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println("not reached") } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/database/connect_errors.silt b/tests/database/connect_errors.silt index f161a3b74..7bed2d5ba 100644 --- a/tests/database/connect_errors.silt +++ b/tests/database/connect_errors.silt @@ -36,7 +36,7 @@ fn said(answer: Result(postgres.PgPool, postgres.PostgresError), told: Bool) -> _ -> "another error" } match told { - true -> "{variant}: {e.message()}" + true -> "{variant}: {Error.message(e)}" false -> variant } } diff --git a/tests/database/connect_to_a_server_that_never_answers.silt b/tests/database/connect_to_a_server_that_never_answers.silt index 13b93673c..93d636653 100644 --- a/tests/database/connect_to_a_server_that_never_answers.silt +++ b/tests/database/connect_to_a_server_that_never_answers.silt @@ -20,7 +20,7 @@ fn until_closed(conn: tcp.TcpStream) -> String { 0 -> "the client closed the connection" _ -> loop() } - Err(e) -> "the read failed: {e.message()}" + Err(e) -> "the read failed: {Error.message(e)}" } } } @@ -38,7 +38,7 @@ fn main() { println("connect: connected") } Err(postgres.Timeout) -> println("connect: Timeout") - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } when let Ok(conn) = task.join(server) else { panic("cannot accept") diff --git a/tests/database/dates_go_back_as_they_were_read.silt b/tests/database/dates_go_back_as_they_were_read.silt index 5a9790f35..27c197d57 100644 --- a/tests/database/dates_go_back_as_they_were_read.silt +++ b/tests/database/dates_go_back_as_they_were_read.silt @@ -89,6 +89,6 @@ fn main() { println("done: {done}") postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/deadline_over_a_statement_in_a_transaction.silt b/tests/database/deadline_over_a_statement_in_a_transaction.silt index 10355837b..c0f7a8fc8 100644 --- a/tests/database/deadline_over_a_statement_in_a_transaction.silt +++ b/tests/database/deadline_over_a_statement_in_a_transaction.silt @@ -33,14 +33,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -90,8 +90,8 @@ fn main() { } match late { Ok(Ok(said)) -> "the function ended with {said}" - Ok(Err(e)) -> "the function ended with {e.message()}" - Err(e) -> "task.deadline: {e.message()}" + Ok(Err(e)) -> "the function ended with {Error.message(e)}" + Err(e) -> "task.deadline: {Error.message(e)}" } } println("statements that wait for it in the server: {until(pool, waiting(), 1)}") @@ -106,6 +106,6 @@ fn main() { let _ = postgres.execute(pool, "DROP TABLE silt_database_deadline_tx", ()) postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/deadline_over_a_statement_in_flight.silt b/tests/database/deadline_over_a_statement_in_flight.silt index be666dc3b..a181c476e 100644 --- a/tests/database/deadline_over_a_statement_in_flight.silt +++ b/tests/database/deadline_over_a_statement_in_flight.silt @@ -30,14 +30,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -76,13 +76,13 @@ fn main() { (), ) { Ok(_) -> "the statement's answer" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } println( match late { Ok(said) -> "the function ended with {said}" - Err(e) -> "task.deadline: {e.message()}" + Err(e) -> "task.deadline: {Error.message(e)}" }, ) println("statements that wait for the lock in the server: {until(pool, waiting(), 1)}") @@ -97,6 +97,6 @@ fn main() { let _ = postgres.execute(pool, "DROP TABLE silt_database_deadline", ()) postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/deadline_while_waiting_for_a_connection.silt b/tests/database/deadline_while_waiting_for_a_connection.silt index cd4c15356..a42a151b8 100644 --- a/tests/database/deadline_while_waiting_for_a_connection.silt +++ b/tests/database/deadline_while_waiting_for_a_connection.silt @@ -31,8 +31,8 @@ fn main() { println( match late { Ok(Ok(said)) -> "the function ended with {said}" - Ok(Err(e)) -> "the function ended with {e.message()}" - Err(e) -> "task.deadline: {e.message()}" + Ok(Err(e)) -> "the function ended with {Error.message(e)}" + Err(e) -> "task.deadline: {Error.message(e)}" }, ) postgres.query(tx, "SELECT 1", (), json.Value) @@ -40,11 +40,11 @@ fn main() { println( match done { Ok(_) -> "main's transaction: Ok" - Err(e) -> "main's transaction: {e.message()}" + Err(e) -> "main's transaction: {Error.message(e)}" }, ) postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/errors_of_statements.silt b/tests/database/errors_of_statements.silt index 0efd779bb..2fd1c9649 100644 --- a/tests/database/errors_of_statements.silt +++ b/tests/database/errors_of_statements.silt @@ -25,14 +25,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -41,7 +41,7 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { fn said(answer: Result(a, postgres.PostgresError)) -> String { match answer { Ok(_) -> "Ok" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } @@ -114,6 +114,6 @@ fn main() { postgres.close(pool) show("a closed pool", postgres.query(pool, "SELECT 1", (), json.Value)) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/execute_counts_and_returning.silt b/tests/database/execute_counts_and_returning.silt index 7e4afe1fd..6d5b5b536 100644 --- a/tests/database/execute_counts_and_returning.silt +++ b/tests/database/execute_counts_and_returning.silt @@ -52,10 +52,10 @@ fn main() { Ok(db) -> { match counts(db) { Ok(left) -> println("left: {left}") - Err(e) -> println("failed: {e.message()}") + Err(e) -> println("failed: {Error.message(e)}") } postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/io_timeout_leaves_a_commit_alone.silt b/tests/database/io_timeout_leaves_a_commit_alone.silt index 311d7660d..756ba6c45 100644 --- a/tests/database/io_timeout_leaves_a_commit_alone.silt +++ b/tests/database/io_timeout_leaves_a_commit_alone.silt @@ -24,14 +24,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -40,7 +40,7 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { fn said(answer: Result(a, postgres.PostgresError)) -> String { match answer { Ok(_) -> "Ok" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } @@ -69,6 +69,6 @@ fn main() { let _ = postgres.execute(pool, "DROP FUNCTION silt_database_io_timeout_slow()", ()) postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/parameters_of_every_type.silt b/tests/database/parameters_of_every_type.silt index 461213a0f..eea2abdbe 100644 --- a/tests/database/parameters_of_every_type.silt +++ b/tests/database/parameters_of_every_type.silt @@ -31,7 +31,7 @@ fn url() -> String { fn show(db: postgres.PgPool, what: String, sql: String, ps: p) { match postgres.query(db, sql, ps, Out) { Ok(rows) -> println("{what}: {rows}") - Err(e) -> println("{what}: {e.message()}") + Err(e) -> println("{what}: {Error.message(e)}") } } @@ -70,10 +70,10 @@ fn main() { show(db, "none", "SELECT 'no parameters' AS v", ()) match postgres.query(db, "SELECT id FROM generate_series(1, 9) AS id WHERE id = ANY($1)", ([2, 5],), Ids) { Ok(rows) -> println("= ANY($1): {rows}") - Err(e) -> println("= ANY($1): {e.message()}") + Err(e) -> println("= ANY($1): {Error.message(e)}") } postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/rows_of_every_decoded_type.silt b/tests/database/rows_of_every_decoded_type.silt index 4d60d268f..e5c09f379 100644 --- a/tests/database/rows_of_every_decoded_type.silt +++ b/tests/database/rows_of_every_decoded_type.silt @@ -92,10 +92,10 @@ fn main() { Ok(db) -> { match row(db) { Ok(_) -> () - Err(e) -> println("failed: {e.message()}") + Err(e) -> println("failed: {Error.message(e)}") } postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/rows_that_do_not_fit.silt b/tests/database/rows_that_do_not_fit.silt index 6b22c7d81..f6f9bd1a8 100644 --- a/tests/database/rows_that_do_not_fit.silt +++ b/tests/database/rows_that_do_not_fit.silt @@ -61,7 +61,7 @@ fn said(e: postgres.PostgresError) -> String { postgres.Other(text) -> "Other({text})" _ -> "another error" } - "{variant}\n {e.message()}" + "{variant}\n {Error.message(e)}" } fn show(what: String, answer: Result(List(a), postgres.PostgresError)) where a: Display { @@ -111,6 +111,6 @@ fn main() { let _ = postgres.execute(db, "DROP TABLE pg2_fit", ()) postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/select_one.silt b/tests/database/select_one.silt index df8e0216d..07557b99f 100644 --- a/tests/database/select_one.silt +++ b/tests/database/select_one.silt @@ -17,10 +17,10 @@ fn main() { Ok(pool) -> { match postgres.query(pool, "SELECT 1 AS one", (), One) { Ok(rows) -> println(rows) - Err(e) -> println("query: {e.message()}") + Err(e) -> println("query: {Error.message(e)}") } postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/stream_and_cursor_of_a_record_type.silt b/tests/database/stream_and_cursor_of_a_record_type.silt index 633e4602f..71b74cd7f 100644 --- a/tests/database/stream_and_cursor_of_a_record_type.silt +++ b/tests/database/stream_and_cursor_of_a_record_type.silt @@ -29,13 +29,13 @@ fn drain(db: postgres.PgPool, sql: String) { loop() } Some(Err(e)) -> { - println(" Err: {e.message()}") + println(" Err: {Error.message(e)}") loop() } None -> println(" closed") } } - Err(e) -> println(" stream: {e.message()}") + Err(e) -> println(" stream: {Error.message(e)}") } } @@ -71,10 +71,10 @@ fn main() { } match refused { Ok(rows) -> println("a cursor that does not fit: {rows}") - Err(e) -> println("a cursor that does not fit: {e.message()}") + Err(e) -> println("a cursor that does not fit: {Error.message(e)}") } postgres.close(db) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/stream_closed_by_its_receiver.silt b/tests/database/stream_closed_by_its_receiver.silt index c7ab5c9cc..2c267eff8 100644 --- a/tests/database/stream_closed_by_its_receiver.silt +++ b/tests/database/stream_closed_by_its_receiver.silt @@ -35,14 +35,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -84,7 +84,7 @@ fn main() { let pad = string.length(row.pad) "the first row: mark {row.silt_database_stream_closed_mark}, a pad of {pad}" } - Some(Err(e)) -> e.message() + Some(Err(e)) -> Error.message(e) _ -> "no row" }, ) @@ -95,14 +95,14 @@ fn main() { println("closed by the receiver") println("sessions that run it after the close: {until(watch, running(), 0)}") } - Err(e) -> println("postgres.stream: {e.message()}") + Err(e) -> println("postgres.stream: {Error.message(e)}") } let after = count(pool, "SELECT 1") println("the pool answers after it: {after} row") postgres.close(pool) postgres.close(watch) } - (Err(e), _) -> println("connect: {e.message()}") - (_, Err(e)) -> println("connect: {e.message()}") + (Err(e), _) -> println("connect: {Error.message(e)}") + (_, Err(e)) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/stream_left_unread.silt b/tests/database/stream_left_unread.silt index 5e7c3fb59..69386792a 100644 --- a/tests/database/stream_left_unread.silt +++ b/tests/database/stream_left_unread.silt @@ -26,14 +26,14 @@ fn main() { println( match channel.receive(rows) { Some(Ok(row)) -> "the first row is {row}" - Some(Err(e)) -> e.message() + Some(Err(e)) -> Error.message(e) _ -> "no row" }, ) println("main returns, the stream unread") } - Err(e) -> println("postgres.stream: {e.message()}") + Err(e) -> println("postgres.stream: {Error.message(e)}") } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/stream_left_unread_in_a_transaction.silt b/tests/database/stream_left_unread_in_a_transaction.silt index 574bdc246..7bd166fdc 100644 --- a/tests/database/stream_left_unread_in_a_transaction.silt +++ b/tests/database/stream_left_unread_in_a_transaction.silt @@ -25,14 +25,14 @@ fn count(pool: postgres.PgPool, sql: String) -> Int { match channel.receive(rows) { Some(Ok(_)) -> loop(n + 1) Some(Err(e)) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } _ -> n } } Err(e) -> { - println("count: {e.message()}") + println("count: {Error.message(e)}") -1 } } @@ -54,7 +54,7 @@ fn main() { println( match channel.receive(rows) { Some(Ok(_)) -> "the stream gave a row" - Some(Err(e)) -> e.message() + Some(Err(e)) -> Error.message(e) _ -> "no row" }, ) @@ -69,6 +69,6 @@ fn main() { let _ = postgres.execute(pool, "DROP TABLE silt_database_stream_in_tx", ()) postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/stream_of_a_cancelled_reader.silt b/tests/database/stream_of_a_cancelled_reader.silt index 4b51f2b80..b48b149c2 100644 --- a/tests/database/stream_of_a_cancelled_reader.silt +++ b/tests/database/stream_of_a_cancelled_reader.silt @@ -27,7 +27,7 @@ fn main() { Ok(rows) -> { let first = match channel.receive(rows) { Some(Ok(_)) -> "the reader has a row" - Some(Err(e)) -> e.message() + Some(Err(e)) -> Error.message(e) _ -> "no row" } channel.send(got, first) @@ -36,7 +36,7 @@ fn main() { let _ = channel.receive(got) () } - Err(e) -> channel.send(got, "postgres.stream: {e.message()}") + Err(e) -> channel.send(got, "postgres.stream: {Error.message(e)}") } } match channel.receive(got) { @@ -46,6 +46,6 @@ fn main() { task.cancel(reader) println("the reader is cancelled, main returns") } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/database/transaction_used_after_its_end.silt b/tests/database/transaction_used_after_its_end.silt index 976126f6d..7c3b1f906 100644 --- a/tests/database/transaction_used_after_its_end.silt +++ b/tests/database/transaction_used_after_its_end.silt @@ -20,7 +20,7 @@ fn said(answer: Result(a, postgres.PostgresError)) -> String { match answer { Ok(_) -> "Ok" Err(postgres.Closed) -> "Closed" - Err(e) -> "another error: {e.message()}" + Err(e) -> "another error: {Error.message(e)}" } } @@ -56,6 +56,6 @@ fn main() { } postgres.close(pool) } - Err(e) -> println("connect: {e.message()}") + Err(e) -> println("connect: {Error.message(e)}") } } diff --git a/tests/golden/cli/disasm/disasm_rendering__a_method_found_by_a_later_argument.silt b/tests/golden/cli/disasm/disasm_rendering__a_method_found_by_a_later_argument.silt new file mode 100644 index 000000000..501702d5a --- /dev/null +++ b/tests/golden/cli/disasm/disasm_rendering__a_method_found_by_a_later_argument.silt @@ -0,0 +1,22 @@ +-- cmd: disasm +-- A call through a trait whose argument of type Self is not the first, +-- on a bounded type variable: `CallMethod` finds the method by that +-- argument, which the disassembly names. +-- stdout-contains: TailCallMethod 0 2 ; "scale" of Scale, by argument 1 +trait Scale { + fn scale(by: Int, x: Self) -> Self +} + +trait Scale for Int { + fn scale(by: Int, x: Self) -> Self { + by * x + } +} + +fn twice(x: a) -> a where a: Scale { + Scale.scale(2, x) +} + +fn main() { + println(twice(5)) +} diff --git a/tests/golden/cli/disasm/disasm_rendering__record_update_method_builtin_variant.silt b/tests/golden/cli/disasm/disasm_rendering__record_update_method_builtin_variant.silt index e0cda824f..d68e0de09 100644 --- a/tests/golden/cli/disasm/disasm_rendering__record_update_method_builtin_variant.silt +++ b/tests/golden/cli/disasm/disasm_rendering__record_update_method_builtin_variant.silt @@ -1,12 +1,11 @@ -- cmd: disasm --- The operand rendering of the opcodes main compiles to. `q.display()` --- on a record with no Display impl of its own is the VM's own method --- of the trait (CallMethod). +-- The operand rendering of the opcodes main compiles to. `Hash.hash(q)` +-- on a record is the VM's own method of the trait (CallMethod). -- (Variant construction compiles to the constructor as a constant + Call.) -- stdout-contains: == main (arity=0, upvalues=0) == -- stdout-contains: RecordUpdate 1 -- stdout-contains: | field 3 ; "x" --- stdout-contains: CallMethod 0 1 ; "display" of Display +-- stdout-contains: CallMethod 0 1 ; "hash" of Hash -- stdout-contains: CallBuiltin 1 ; string.length -- stdout-contains: Constant 8 ; import string @@ -21,7 +20,7 @@ type Shape { fn main() { let p = Point { x: 1, y: 2 } let q = p.{ x: 5 } - println(q.display()) + println(Hash.hash(q)) println(string.length("abc")) let s = Circle(3) println(s) diff --git a/tests/golden/cli/disasm/disasm_slots__globals_named_by_definition/main.silt b/tests/golden/cli/disasm/disasm_slots__globals_named_by_definition/main.silt index cd88bb7ae..4d67fb837 100644 --- a/tests/golden/cli/disasm/disasm_slots__globals_named_by_definition/main.silt +++ b/tests/golden/cli/disasm/disasm_slots__globals_named_by_definition/main.silt @@ -8,10 +8,11 @@ -- stdout-contains: ; util.secret -- stdout-contains: ; Pt.display import util +import string type Pt { x: Int } trait Display for Pt { fn display(self) -> String { "pt" } } let limit = 3 fn main() { println(util.helper(limit)) - println(Pt { x: 1 }.display()) + println(string.from(Pt { x: 1 })) } diff --git a/tests/golden/cli/doors/stage5_doors__trait_item_import_runs/main.silt b/tests/golden/cli/doors/stage5_doors__trait_item_import_runs/main.silt index bbbb90fec..2d3d03aba 100644 --- a/tests/golden/cli/doors/stage5_doors__trait_item_import_runs/main.silt +++ b/tests/golden/cli/doors/stage5_doors__trait_item_import_runs/main.silt @@ -9,6 +9,6 @@ fn first(p: Pair(Int)) -> Int { } fn main() { - println(5.describe()) + println(Describe.describe(5)) println(first((1, 2))) } diff --git a/tests/golden/cli/repl/repl__a_failed_entry__display_impl_with_a_wrong_body.silt b/tests/golden/cli/repl/repl__a_failed_entry__display_impl_with_a_wrong_body.silt index fa8c89e6c..4642c0873 100644 --- a/tests/golden/cli/repl/repl__a_failed_entry__display_impl_with_a_wrong_body.silt +++ b/tests/golden/cli/repl/repl__a_failed_entry__display_impl_with_a_wrong_body.silt @@ -1,5 +1,5 @@ -- cmd: repl -- stderr-contains: type mismatch: expected String, got Int --- stdin: type U { U(Int) }\n"{U(1)}"\ntrait Display for U { fn display(self) -> String { 3 } }\n"{U(1)}"\nU(2)\n[U(3)]\nU(4).display()\nprintln(U(5))\nfn show(x: a) -> String where a: Display { "{x}" }\nshow(U(6))\nU(7) == U(7)\n:quit\n +-- stdin: type U { U(Int) }\n"{U(1)}"\ntrait Display for U { fn display(self) -> String { 3 } }\n"{U(1)}"\nU(2)\n[U(3)]\n"{U(4)}"\nprintln(U(5))\nfn show(x: a) -> String where a: Display { "{x}" }\nshow(U(6))\nU(7) == U(7)\n:quit\n -- An entry that writes a Display impl and fails leaves the session as it -- was: the type is shown, printed and bounded by its structure as before. diff --git a/tests/golden/cli/repl/repl__a_failed_entry__second_trait_with_a_method_of_the_same_name.silt b/tests/golden/cli/repl/repl__a_failed_entry__second_trait_with_a_method_of_the_same_name.silt index e744263f5..d6767880d 100644 --- a/tests/golden/cli/repl/repl__a_failed_entry__second_trait_with_a_method_of_the_same_name.silt +++ b/tests/golden/cli/repl/repl__a_failed_entry__second_trait_with_a_method_of_the_same_name.silt @@ -1,7 +1,6 @@ -- cmd: repl -- stderr-contains: type mismatch: expected Int, got String --- stderr-contains: ambiguous method 'm' on type 'U': provided by traits --- stdin: type U { U(Int) }\ntrait A { fn m(self) -> String }\ntrait A for U { fn m(self) -> String { "a" } }\nU(1).m()\ntrait B { fn m(self) -> Int }\nU(1).m()\ntrait B for U { fn m(self) -> Int { "bad" } }\nU(1).m()\nfn go(x: U) -> String { x.m() }\ngo(U(2))\ntrait B for U { fn m(self) -> Int { 7 } }\nU(1).m()\n:quit\n +-- stdin: type U { U(Int) }\ntrait A { fn m(self) -> String }\ntrait A for U { fn m(self) -> String { "a" } }\nA.m(U(1))\ntrait B { fn m(self) -> Int }\nA.m(U(1))\ntrait B for U { fn m(self) -> Int { "bad" } }\nA.m(U(1))\nfn go(x: U) -> String { A.m(x) }\ngo(U(2))\ntrait B for U { fn m(self) -> Int { 7 } }\nA.m(U(1))\nB.m(U(1))\n:quit\n -- Two traits with a method `m`: the failed impl of the second leaves the -- first one's `m` (it was lost: the row of the method table was written --- over). With both impls the call is ambiguous. +-- over). With both impls each call names its trait. diff --git a/tests/golden/cli/repl/repl__a_failed_entry__second_trait_with_a_method_of_the_same_name.stdout b/tests/golden/cli/repl/repl__a_failed_entry__second_trait_with_a_method_of_the_same_name.stdout index 726c5d362..551f27b94 100644 --- a/tests/golden/cli/repl/repl__a_failed_entry__second_trait_with_a_method_of_the_same_name.stdout +++ b/tests/golden/cli/repl/repl__a_failed_entry__second_trait_with_a_method_of_the_same_name.stdout @@ -3,3 +3,5 @@ a a a a +a +7 diff --git a/tests/golden/cli/repl/repl__a_failed_entry__user_trait_with_structural_method_names.silt b/tests/golden/cli/repl/repl__a_failed_entry__user_trait_with_structural_method_names.silt index 136c5581f..78b6fef71 100644 --- a/tests/golden/cli/repl/repl__a_failed_entry__user_trait_with_structural_method_names.silt +++ b/tests/golden/cli/repl/repl__a_failed_entry__user_trait_with_structural_method_names.silt @@ -1,5 +1,5 @@ -- cmd: repl -- stderr-contains: type mismatch: expected Int, got String --- stdin: type U { U(Int) }\ntrait Mine { fn equal(self, o: Self) -> Int\n fn hash(self) -> String\n fn display(self) -> Int }\nU(1).equal(U(1))\ntrait Mine for U { fn equal(self, o: Self) -> Int { "bad" }\n fn hash(self) -> String { "h" }\n fn display(self) -> Int { 1 } }\nU(1).equal(U(1))\nU(1) == U(1)\n#{ U(1): 1 }\n"{U(1)}"\nU(1).display()\nfn need_e(x: a) -> Int where a: Equal { 1 }\nneed_e(U(1))\n:quit\n +-- stdin: type U { U(Int) }\ntrait Mine { fn equal(self, o: Self) -> Int\n fn hash(self) -> String\n fn display(self) -> Int }\nU(1) == U(1)\ntrait Mine for U { fn equal(self, o: Self) -> Int { "bad" }\n fn hash(self) -> String { "h" }\n fn display(self) -> Int { 1 } }\nU(1) == U(1)\nU(1) == U(1)\n#{ U(1): 1 }\n"{U(1)}"\n"{U(1)}"\nfn need_e(x: a) -> Int where a: Equal { 1 }\nneed_e(U(1))\n:quit\n -- A trait of the session with methods named `equal`, `hash` and `display`: -- its failed impl changes nothing of what those names mean for the type. diff --git a/tests/golden/cli/repl/repl__a_trait_method_on_a_type_variable_is_checked_at_a_later_entry.silt b/tests/golden/cli/repl/repl__a_trait_method_on_a_type_variable_is_checked_at_a_later_entry.silt index 6b2b71355..b5d2bbab0 100644 --- a/tests/golden/cli/repl/repl__a_trait_method_on_a_type_variable_is_checked_at_a_later_entry.silt +++ b/tests/golden/cli/repl/repl__a_trait_method_on_a_type_variable_is_checked_at_a_later_entry.silt @@ -1,5 +1,5 @@ -- cmd: repl --- stdin: import json\ntype Src { s: String }\ntrait Loader { fn load(self, type a) -> Result(a, json.JsonError) where a: json.Decode }\ntrait Loader for Src { fn load(self, type a) -> Result(a, json.JsonError) { json.parse(self.s, a) } }\nfn go(l: l, type b) -> Result(b, json.JsonError) where l: Loader, b: json.Decode { l.load(b) }\ntype Blob { b: Bytes }\ntype Fine { n: Int }\ngo(Src { s: "\{\"n\": 1}" }, Fine)\ngo(Src { s: "\{}" }, Blob)\n:quit\n +-- stdin: import json\ntype Src { s: String }\ntrait Loader { fn load(self, type a) -> Result(a, json.JsonError) where a: json.Decode }\ntrait Loader for Src { fn load(self, type a) -> Result(a, json.JsonError) { json.parse(self.s, a) } }\nfn go(l: l, type b) -> Result(b, json.JsonError) where l: Loader, b: json.Decode { Loader.load(l, b) }\ntype Blob { b: Bytes }\ntype Fine { n: Int }\ngo(Src { s: "\{\"n\": 1}" }, Fine)\ngo(Src { s: "\{}" }, Blob)\n:quit\n -- A trait, its impl and a generic function that calls its method on a -- bounded parameter, each in an entry of its own: a later entry that -- calls the function is checked with the type it gives. diff --git a/tests/golden/cli/repl/repl__an_impl_for_a_type_of_an_earlier_entry.silt b/tests/golden/cli/repl/repl__an_impl_for_a_type_of_an_earlier_entry.silt index b0dd0cdd6..dfe40b51d 100644 --- a/tests/golden/cli/repl/repl__an_impl_for_a_type_of_an_earlier_entry.silt +++ b/tests/golden/cli/repl/repl__an_impl_for_a_type_of_an_earlier_entry.silt @@ -1,5 +1,5 @@ -- cmd: repl --- stdin: type P { n: Int }\nlet p = P { n: 1 }\np\ntrait Display for P { fn display(self) -> String { "#{self.n}" } }\np\n[p, P { n: 2 }]\ntrait Sz { fn sz(self) -> Int }\ntrait Sz for P { fn sz(self) -> Int { self.n } }\np.sz()\n:quit\n +-- stdin: type P { n: Int }\nlet p = P { n: 1 }\np\ntrait Display for P { fn display(self) -> String { "#{self.n}" } }\np\n[p, P { n: 2 }]\ntrait Sz { fn sz(self) -> Int }\ntrait Sz for P { fn sz(self) -> Int { self.n } }\nSz.sz(p)\n:quit\n -- The entries of one session count as one module for where an impl is -- written: a type of one entry gets its `Display` impl, and an impl of -- a trait of another entry, in a later one. A value made before the diff --git a/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__redefined_but_referred_to.silt b/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__redefined_but_referred_to.silt index 927e7ced4..9d00195ec 100644 --- a/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__redefined_but_referred_to.silt +++ b/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__redefined_but_referred_to.silt @@ -1,5 +1,5 @@ -- cmd: repl --- stdin: trait Greet { fn greet(self) -> String }\ntrait Greet for Int { fn greet(self) -> String { "int" } }\nfn hello(x: a) -> String where a: Greet { x.greet() }\nimport channel\nlet ch = channel.new(4)\nfn f() {\n match channel.try_receive(ch) {\n channel.Message(m) -> println(hello(m))\n _ -> println("none")\n }\n}\nfn g() { f() }\nfn f() { println("new f") }\nchannel.send(ch, "s")\ng()\n:quit\n +-- stdin: trait Greet { fn greet(self) -> String }\ntrait Greet for Int { fn greet(self) -> String { "int" } }\nfn hello(x: a) -> String where a: Greet { Greet.greet(x) }\nimport channel\nlet ch = channel.new(4)\nfn f() {\n match channel.try_receive(ch) {\n channel.Message(m) -> println(hello(m))\n _ -> println("none")\n }\n}\nfn g() { f() }\nfn f() { println("new f") }\nchannel.send(ch, "s")\ng()\n:quit\n -- stderr-contains: error[type]: this input gives a value a type an earlier input does not allow: type 'String' does not implement trait 'Greet' -- stderr-contains: --> :1:1 -- A cell is bound to what its names meant when it was entered: `g` diff --git a/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__redefined_function.silt b/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__redefined_function.silt index 081bc2c52..c82ee6568 100644 --- a/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__redefined_function.silt +++ b/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__redefined_function.silt @@ -1,5 +1,5 @@ -- cmd: repl --- stdin: trait Greet { fn greet(self) -> String }\ntrait Greet for Int { fn greet(self) -> String { "int" } }\nfn hello(x: a) -> String where a: Greet { x.greet() }\nimport channel\nlet ch = channel.new(4)\nfn f() {\n match channel.try_receive(ch) {\n channel.Message(m) -> println(hello(m))\n _ -> println("none")\n }\n}\nfn f() { println("new f") }\nchannel.send(ch, "s")\nf()\n:quit\n +-- stdin: trait Greet { fn greet(self) -> String }\ntrait Greet for Int { fn greet(self) -> String { "int" } }\nfn hello(x: a) -> String where a: Greet { Greet.greet(x) }\nimport channel\nlet ch = channel.new(4)\nfn f() {\n match channel.try_receive(ch) {\n channel.Message(m) -> println(hello(m))\n _ -> println("none")\n }\n}\nfn f() { println("new f") }\nchannel.send(ch, "s")\nf()\n:quit\n -- stderr-not-contains: error -- A check that waits in a function's body goes with the function: once -- `f` is defined again and nothing refers to the old one, the channel diff --git a/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__where_bound.silt b/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__where_bound.silt index 894797206..a6d1b1c6b 100644 --- a/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__where_bound.silt +++ b/tests/golden/cli/repl/repl__check_waits_for_a_later_cell__where_bound.silt @@ -1,5 +1,5 @@ -- cmd: repl --- stdin: trait Greet { fn greet(self) -> String }\ntrait Greet for Int { fn greet(self) -> String { "int" } }\nfn hello(x: a) -> String where a: Greet { x.greet() }\nimport channel\nlet ch = channel.new(4)\nfn f() {\n match channel.receive(ch) {\n Some(m) -> println(hello(m))\n None -> ()\n }\n}\nchannel.send(ch, "s")\nchannel.send(ch, 3)\nf()\n:quit\n +-- stdin: trait Greet { fn greet(self) -> String }\ntrait Greet for Int { fn greet(self) -> String { "int" } }\nfn hello(x: a) -> String where a: Greet { Greet.greet(x) }\nimport channel\nlet ch = channel.new(4)\nfn f() {\n match channel.receive(ch) {\n Some(m) -> println(hello(m))\n None -> ()\n }\n}\nchannel.send(ch, "s")\nchannel.send(ch, 3)\nf()\n:quit\n -- stderr-contains: error[type]: this input gives a value a type an earlier input does not allow: type 'String' does not implement trait 'Greet' -- stderr-contains: --> :1:1 -- stderr-contains: ::: :3:30 diff --git a/tests/golden/cli/repl/repl__default_method_of_a_trait_of_an_earlier_entry.silt b/tests/golden/cli/repl/repl__default_method_of_a_trait_of_an_earlier_entry.silt index d64f7da31..000135f22 100644 --- a/tests/golden/cli/repl/repl__default_method_of_a_trait_of_an_earlier_entry.silt +++ b/tests/golden/cli/repl/repl__default_method_of_a_trait_of_an_earlier_entry.silt @@ -1,5 +1,5 @@ -- cmd: repl --- stdin: type P { n: Int }\ntrait Sz { fn sz(self) -> Int fn dbl(self) -> Int { self.sz() * 2 } }\ntrait Sz for Int { fn sz(self) -> Int { self } }\n4.dbl()\nfn dy(x: a) -> Int where a: Sz { x.dbl() }\ndy(4)\nlet k = 5\ntrait Sz for P { fn sz(self) -> Int { self.n + k } }\nP { n: 1 }.sz()\nP { n: 1 }.dbl()\ndy(P { n: 2 })\nP.sz(P { n: 9 })\nP.dbl(P { n: 9 })\nimport list\nlist.map([P { n: 1 }], P.dbl)\n:quit\n +-- stdin: type P { n: Int }\ntrait Sz { fn sz(self) -> Int fn dbl(self) -> Int { Sz.sz(self) * 2 } }\ntrait Sz for Int { fn sz(self) -> Int { self } }\nSz.dbl(4)\nfn dy(x: a) -> Int where a: Sz { Sz.dbl(x) }\ndy(4)\nlet k = 5\ntrait Sz for P { fn sz(self) -> Int { self.n + k } }\nSz.sz(P { n: 1 })\nSz.dbl(P { n: 1 })\ndy(P { n: 2 })\nSz.sz(P { n: 9 })\nSz.dbl(P { n: 9 })\nimport list\nlist.map([P { n: 1 }], Sz.dbl)\n:quit\n -- A default method is the trait's one function, for every impl that -- leaves it out, whichever entry declared the trait: an impl written -- in a later entry (`trait Sz for P`), and one of the same entry as the diff --git a/tests/golden/cli/repl/repl__field_method__impl_in_a_later_entry.silt b/tests/golden/cli/repl/repl__field_method__impl_in_a_later_entry.silt index 7720cbc86..2d4b5b2f7 100644 --- a/tests/golden/cli/repl/repl__field_method__impl_in_a_later_entry.silt +++ b/tests/golden/cli/repl/repl__field_method__impl_in_a_later_entry.silt @@ -1,5 +1,5 @@ -- cmd: repl --- stdin: type H { run: Int, n: Int }\ntrait Run { fn run(self) -> Int }\ntrait Run for H { fn run(self) -> Int { 7 } }\nlet h = H { run: 1, n: 2 }\nh.run\nfn bounded(r: a) -> Int where a: Run { r.run() }\nbounded(h)\ntrait Run for Int { fn run(self) -> Int { self } }\nbounded(3)\n:quit\n +-- stdin: type H { run: Int, n: Int }\ntrait Run { fn run(self) -> Int }\ntrait Run for H { fn run(self) -> Int { 7 } }\nlet h = H { run: 1, n: 2 }\nh.run\nfn bounded(r: a) -> Int where a: Run { Run.run(r) }\nbounded(h)\ntrait Run for Int { fn run(self) -> Int { self } }\nbounded(3)\n:quit\n -- An entry that adds an impl whose method is named like a field of a -- record of an earlier entry is the error, and adds nothing: the -- session goes on without the impl (`bounded(h)` has no `Run` for `H`). diff --git a/tests/golden/cli/repl/repl__field_method__redeclared_type_is_a_new_type.silt b/tests/golden/cli/repl/repl__field_method__redeclared_type_is_a_new_type.silt index 195c7f574..306fd5a5c 100644 --- a/tests/golden/cli/repl/repl__field_method__redeclared_type_is_a_new_type.silt +++ b/tests/golden/cli/repl/repl__field_method__redeclared_type_is_a_new_type.silt @@ -1,5 +1,5 @@ -- cmd: repl --- stdin: type H { n: Int }\ntrait Run { fn run(self) -> Int }\ntrait Run for H { fn run(self) -> Int { 7 } }\nlet old = H { n: 2 }\ntype H { run: Int, n: Int }\nlet new = H { run: 1, n: 2 }\nold.run()\nnew.run\nfn bounded(r: a) -> Int where a: Run { r.run() }\nbounded(old)\nbounded(new)\ntrait Run for H { fn run(self) -> Int { 8 } }\n:quit\n +-- stdin: type H { n: Int }\ntrait Run { fn run(self) -> Int }\ntrait Run for H { fn run(self) -> Int { 7 } }\nlet old = H { n: 2 }\ntype H { run: Int, n: Int }\nlet new = H { run: 1, n: 2 }\nRun.run(old)\nnew.run\nfn bounded(r: a) -> Int where a: Run { Run.run(r) }\nbounded(old)\nbounded(new)\ntrait Run for H { fn run(self) -> Int { 8 } }\n:quit\n -- A type declared again is a new type with no impls (stage 5 decision -- D4): declaring `H` again with a field `run` is no clash with the impl -- of `Run` for the old `H`, which the old values keep. The new `H` has diff --git a/tests/golden/cli/repl/repl__json_encode_s_method_needs_import_json.silt b/tests/golden/cli/repl/repl__json_encode_s_method_needs_import_json.silt index e76a56f7f..e6d0ebbec 100644 --- a/tests/golden/cli/repl/repl__json_encode_s_method_needs_import_json.silt +++ b/tests/golden/cli/repl/repl__json_encode_s_method_needs_import_json.silt @@ -1,7 +1,6 @@ -- cmd: repl --- stderr-contains: unknown field or method 'encode' on type P --- stderr-contains: unknown method 'encode' on type Int +-- stderr-contains: module 'json' is not imported -- stdout-contains: Object(#{"x": Int(1)}) --- stdin: type P { x: Int }\nP { x: 1 }.encode()\n1.encode()\nimport json\nP { x: 1 }.encode()\n:quit\n --- In the REPL too, `encode` is a value's method once an entry imports +-- stdin: type P { x: Int }\njson.Encode.encode(P { x: 1 })\nimport json\njson.Encode.encode(P { x: 1 })\n:quit\n +-- In the REPL too, `json.Encode.encode` is called once an entry imports -- json, and not before. diff --git a/tests/golden/cli/repl/repl__redefined_type_keeps_its_impls.silt b/tests/golden/cli/repl/repl__redefined_type_keeps_its_impls.silt index 49fb608b4..5e8eaebbd 100644 --- a/tests/golden/cli/repl/repl__redefined_type_keeps_its_impls.silt +++ b/tests/golden/cli/repl/repl__redefined_type_keeps_its_impls.silt @@ -1,5 +1,5 @@ -- cmd: repl --- stdin: type P { x: Int }\ntrait Display for P { fn display(self) -> String { "old P" } }\nlet a = P { x: 1 }\ntype P { x: Int }\ntrait Display for P { fn display(self) -> String { "new P" } }\nlet b = P { x: 2 }\na.display()\nb.display()\n:quit\n +-- stdin: type P { x: Int }\ntrait Display for P { fn display(self) -> String { "old P" } }\nlet a = P { x: 1 }\ntype P { x: Int }\ntrait Display for P { fn display(self) -> String { "new P" } }\nlet b = P { x: 2 }\n"{a}"\n"{b}"\n:quit\n -- Redefinition is early-bound (stage 5 decision D4): a type declared -- again is a new type with impls of its own, so a value of the old type -- keeps the old type's Display impl. diff --git a/tests/golden/cli/repl/repl__trait_impl_replaces_the_derived_one.silt b/tests/golden/cli/repl/repl__trait_impl_replaces_the_derived_one.silt index ed7b61ce1..9ddfa019b 100644 --- a/tests/golden/cli/repl/repl__trait_impl_replaces_the_derived_one.silt +++ b/tests/golden/cli/repl/repl__trait_impl_replaces_the_derived_one.silt @@ -1,5 +1,5 @@ -- cmd: repl --- stdin: type Box { v: Int }\ntrait Display for Box { fn display(self) -> String { "Box({self.v})" } }\n1 + 1\nlet b = Box { v: 3 }\nb.display()\n"{b.display()} {b == Box { v: 3 }}"\ntrait Display for Box { fn display(self) -> String { "again" } }\nb.display()\nfn show(x: Box) -> String { x.display() }\nshow(Box { v: 4 })\n:quit\n +-- stdin: type Box { v: Int }\ntrait Display for Box { fn display(self) -> String { "Box({self.v})" } }\n1 + 1\nlet b = Box { v: 3 }\n"{b}"\n"{b} {b == Box { v: 3 }}"\ntrait Display for Box { fn display(self) -> String { "again" } }\n"{b}"\nfn show(x: Box) -> String { "{x}" }\nshow(Box { v: 4 })\n:quit\n -- stderr-contains: error[type]: duplicate implementation of trait 'Display' for type 'Box' -- stderr-contains: --> :1:1 -- A written `Display` impl for a type of an earlier input replaces the diff --git a/tests/golden/concurrency/deadline/task_deadline__a_read_in_flight_is_shut_down.silt b/tests/golden/concurrency/deadline/task_deadline__a_read_in_flight_is_shut_down.silt index 4bc32e3f0..a4960a9ec 100644 --- a/tests/golden/concurrency/deadline/task_deadline__a_read_in_flight_is_shut_down.silt +++ b/tests/golden/concurrency/deadline/task_deadline__a_read_in_flight_is_shut_down.silt @@ -25,6 +25,6 @@ fn main() { match tcp.read(conn, 16) { Err(tcp.Closed) -> println("then the connection is closed") Ok(read) -> println("then still open (read {bytes.length(read)})") - Err(e) -> println("then {e.message()}") + Err(e) -> println("then {Error.message(e)}") } } diff --git a/tests/golden/concurrency/deadline/task_deadline__ends_a_pending_accept.silt b/tests/golden/concurrency/deadline/task_deadline__ends_a_pending_accept.silt index dac349413..0bf205305 100644 --- a/tests/golden/concurrency/deadline/task_deadline__ends_a_pending_accept.silt +++ b/tests/golden/concurrency/deadline/task_deadline__ends_a_pending_accept.silt @@ -14,8 +14,8 @@ fn main() { match task.deadline(time.ms(50), { -> tcp.accept(listener) }) { Err(task.Timeout) -> println("the deadline passed") Ok(Ok(_)) -> println("accepted a connection") - Ok(Err(e)) -> println("tcp: {e.message()}") - Err(e) -> println(e.message()) + Ok(Err(e)) -> println("tcp: {Error.message(e)}") + Err(e) -> println(Error.message(e)) } -- The listener is as it was: a connection is accepted. when let Ok(_) = tcp.connect("127.0.0.1:{tcp.local_port(listener)}") else { panic("cannot connect") } diff --git a/tests/golden/concurrency/deadline/task_deadline__gives_ok_of_what_the_function_returns.silt b/tests/golden/concurrency/deadline/task_deadline__gives_ok_of_what_the_function_returns.silt index 78161af26..46618b7bb 100644 --- a/tests/golden/concurrency/deadline/task_deadline__gives_ok_of_what_the_function_returns.silt +++ b/tests/golden/concurrency/deadline/task_deadline__gives_ok_of_what_the_function_returns.silt @@ -17,6 +17,6 @@ fn main() { match run(time.seconds(60), { -> [1, 2, 3] }) { Ok(xs) -> println(xs) Err(task.Timeout) -> println("timed out") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/concurrency/io/conventions__a_handler_answers_a_malformed_query_itself.silt b/tests/golden/concurrency/io/conventions__a_handler_answers_a_malformed_query_itself.silt index 67530a49e..8c178c1e9 100644 --- a/tests/golden/concurrency/io/conventions__a_handler_answers_a_malformed_query_itself.silt +++ b/tests/golden/concurrency/io/conventions__a_handler_answers_a_malformed_query_itself.silt @@ -33,7 +33,7 @@ fn main() { list.each(["/?name=a%20b", "/?name=%ZZ", "/?name=%FF", "/?other=1", "/?name=c"]) { path -> match http.get("{base}{path}") { Ok(r) -> println("{r.status} {text(r.body)}") - Err(e) -> println("error: {e.message()}") + Err(e) -> println("error: {Error.message(e)}") } } task.cancel(server) diff --git a/tests/golden/concurrency/io/conventions__a_request_s_header_names_are_lower_case_and_its_body_is_bytes.silt b/tests/golden/concurrency/io/conventions__a_request_s_header_names_are_lower_case_and_its_body_is_bytes.silt index dfe416527..7f78564e2 100644 --- a/tests/golden/concurrency/io/conventions__a_request_s_header_names_are_lower_case_and_its_body_is_bytes.silt +++ b/tests/golden/concurrency/io/conventions__a_request_s_header_names_are_lower_case_and_its_body_is_bytes.silt @@ -62,7 +62,7 @@ fn main() { println(ask(port, bytes.from_list([0, 255, 254, 104]) |> result.unwrap_or(bytes.empty()))) match http.get("http://127.0.0.1:{port}/") { Ok(r) -> println("{map.get(r.headers, "x-answered-by")} {map.contains(r.headers, "X-Answered-By")}") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } task.cancel(server) } diff --git a/tests/golden/concurrency/io/http_bodies__a_body_is_text_only_where_the_program_says_so.silt b/tests/golden/concurrency/io/http_bodies__a_body_is_text_only_where_the_program_says_so.silt index c0fdc2858..5561d02bf 100644 --- a/tests/golden/concurrency/io/http_bodies__a_body_is_text_only_where_the_program_says_so.silt +++ b/tests/golden/concurrency/io/http_bodies__a_body_is_text_only_where_the_program_says_so.silt @@ -44,7 +44,7 @@ fn main() { println("{what}") match http.request(http.POST, url, body, #{}) { Ok(resp) -> println(" the client: {bytes.to_hex(resp.body)} {as_text(resp.body)}") - Err(e) -> println(" the client: {e.message()}") + Err(e) -> println(" the client: {Error.message(e)}") } } task.cancel(server) diff --git a/tests/golden/concurrency/io/http_bodies__a_body_over_the_limit_is_an_error_not_a_cut_body.silt b/tests/golden/concurrency/io/http_bodies__a_body_over_the_limit_is_an_error_not_a_cut_body.silt index ffa1fc94c..ce91955a4 100644 --- a/tests/golden/concurrency/io/http_bodies__a_body_over_the_limit_is_an_error_not_a_cut_body.silt +++ b/tests/golden/concurrency/io/http_bodies__a_body_over_the_limit_is_an_error_not_a_cut_body.silt @@ -72,7 +72,7 @@ fn show(what: String, got: Result(http.Response, http.HttpError)) { println("{what}: Ok, {length} bytes, the last is {bytes.get(resp.body, length - 1)}") } Err(http.InvalidResponse(why)) -> println("{what}: Err(InvalidResponse(\"{why}\"))") - Err(e) -> println("{what}: another error: {e.message()}") + Err(e) -> println("{what}: another error: {Error.message(e)}") } } diff --git a/tests/golden/concurrency/io/http_bodies__a_chunked_body_arrives_whole.silt b/tests/golden/concurrency/io/http_bodies__a_chunked_body_arrives_whole.silt index 18bbb1ac3..1d059b2d0 100644 --- a/tests/golden/concurrency/io/http_bodies__a_chunked_body_arrives_whole.silt +++ b/tests/golden/concurrency/io/http_bodies__a_chunked_body_arrives_whole.silt @@ -118,6 +118,6 @@ fn main() { task.join(writer) match got { Ok(resp) -> show(" http.get gets", resp.body) - Err(e) -> println(" http.get: {e.message()}") + Err(e) -> println(" http.get: {Error.message(e)}") } } diff --git a/tests/golden/concurrency/io/http_bodies__a_handler_s_answer_has_the_content_type_it_sets_and_no_other.silt b/tests/golden/concurrency/io/http_bodies__a_handler_s_answer_has_the_content_type_it_sets_and_no_other.silt index d80243e00..007ad7f7e 100644 --- a/tests/golden/concurrency/io/http_bodies__a_handler_s_answer_has_the_content_type_it_sets_and_no_other.silt +++ b/tests/golden/concurrency/io/http_bodies__a_handler_s_answer_has_the_content_type_it_sets_and_no_other.silt @@ -38,7 +38,7 @@ fn main() { ["/text", "/set", "/empty", "/bytes"] |> list.each { path -> match http.get("http://127.0.0.1:{port}{path}") { Ok(resp) -> println("{path}: {bytes.to_hex(resp.body)}, content-type {map.get(resp.headers, "content-type")}") - Err(e) -> println("{path}: {e.message()}") + Err(e) -> println("{path}: {Error.message(e)}") } } diff --git a/tests/golden/concurrency/io/http_bodies__a_head_request_gets_the_length_and_no_body.silt b/tests/golden/concurrency/io/http_bodies__a_head_request_gets_the_length_and_no_body.silt index abc0d6084..6eae62a79 100644 --- a/tests/golden/concurrency/io/http_bodies__a_head_request_gets_the_length_and_no_body.silt +++ b/tests/golden/concurrency/io/http_bodies__a_head_request_gets_the_length_and_no_body.silt @@ -84,7 +84,7 @@ fn main() { println("http.request") match http.request(http.HEAD, "http://127.0.0.1:{port}/", bytes.empty(), #{}) { Ok(resp) -> println(" gets {resp.status}, content-length {map.get(resp.headers, "content-length")}, {bytes.length(resp.body)} bytes") - Err(e) -> println(" {e.message()}") + Err(e) -> println(" {Error.message(e)}") } println("a client written by hand") diff --git a/tests/golden/concurrency/io/http_bodies__an_answer_without_a_body_that_says_packed_is_empty.silt b/tests/golden/concurrency/io/http_bodies__an_answer_without_a_body_that_says_packed_is_empty.silt index 36d331edd..b6eb326ae 100644 --- a/tests/golden/concurrency/io/http_bodies__an_answer_without_a_body_that_says_packed_is_empty.silt +++ b/tests/golden/concurrency/io/http_bodies__an_answer_without_a_body_that_says_packed_is_empty.silt @@ -35,7 +35,7 @@ fn main() { let named = ["content-encoding", "content-length", "etag"] |> list.filter { name -> map.contains(resp.headers, name) } println("{method} {path}: {resp.status}, {bytes.length(resp.body)} bytes, of the three headers: {named}") } - Err(e) -> println("{method} {path}: Err {e.message()}") + Err(e) -> println("{method} {path}: Err {Error.message(e)}") } } task.cancel(server) diff --git a/tests/golden/concurrency/io/http_bodies__an_empty_body_is_empty_at_the_four_places.silt b/tests/golden/concurrency/io/http_bodies__an_empty_body_is_empty_at_the_four_places.silt index 8ebe021df..045e7c819 100644 --- a/tests/golden/concurrency/io/http_bodies__an_empty_body_is_empty_at_the_four_places.silt +++ b/tests/golden/concurrency/io/http_bodies__an_empty_body_is_empty_at_the_four_places.silt @@ -79,7 +79,7 @@ fn main() { let server = task.spawn { -> http.serve(listener, answer) } match http.request(http.POST, "http://127.0.0.1:{port}/", bytes.empty(), #{}) { Ok(resp) -> println(" http.request gets: {resp.status}, {bytes.length(resp.body)} bytes, equal to bytes.empty(): {resp.body == bytes.empty()}") - Err(e) -> println(" http.request: {e.message()}") + Err(e) -> println(" http.request: {Error.message(e)}") } println("a client written by hand to http.serve") @@ -105,6 +105,6 @@ fn main() { println(" the request on the wire: {length_line(sent)}, {bytes.length(body_of(sent) |> option.unwrap_or(bytes.empty()))} bytes after the head") match got { Ok(resp) -> println(" http.request gets: {resp.status}, {bytes.length(resp.body)} bytes, equal to bytes.empty(): {resp.body == bytes.empty()}") - Err(e) -> println(" http.request: {e.message()}") + Err(e) -> println(" http.request: {Error.message(e)}") } } diff --git a/tests/golden/concurrency/io/http_bodies__every_byte_value_arrives_at_the_four_places.silt b/tests/golden/concurrency/io/http_bodies__every_byte_value_arrives_at_the_four_places.silt index 880bc617e..7a5936f4c 100644 --- a/tests/golden/concurrency/io/http_bodies__every_byte_value_arrives_at_the_four_places.silt +++ b/tests/golden/concurrency/io/http_bodies__every_byte_value_arrives_at_the_four_places.silt @@ -83,7 +83,7 @@ fn main() { let server = task.spawn { -> http.serve(listener, answer) } match http.request(http.POST, "http://127.0.0.1:{port}/", upwards(), #{}) { Ok(resp) -> show(" http.request gets", resp.body) - Err(e) -> println(" http.request: {e.message()}") + Err(e) -> println(" http.request: {Error.message(e)}") } -- The client says that it closes, so the answer ends where the @@ -110,6 +110,6 @@ fn main() { show(" the request on the wire", task.join(reader)) match got { Ok(resp) -> show(" http.request gets", resp.body) - Err(e) -> println(" http.request: {e.message()}") + Err(e) -> println(" http.request: {Error.message(e)}") } } diff --git a/tests/golden/concurrency/io/http_client__a_request_says_silt_and_its_version_unless_the_program_says_otherwise.silt b/tests/golden/concurrency/io/http_client__a_request_says_silt_and_its_version_unless_the_program_says_otherwise.silt index 3a011994d..215bc27b1 100644 --- a/tests/golden/concurrency/io/http_client__a_request_says_silt_and_its_version_unless_the_program_says_otherwise.silt +++ b/tests/golden/concurrency/io/http_client__a_request_says_silt_and_its_version_unless_the_program_says_otherwise.silt @@ -39,7 +39,7 @@ fn shown(got: Result(http.Response, http.HttpError)) -> String { _ -> agent } } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/concurrency/io/io_op__a_given_up_tls_connect_frees_its_thread.silt b/tests/golden/concurrency/io/io_op__a_given_up_tls_connect_frees_its_thread.silt index 31666b7d6..53ea92941 100644 --- a/tests/golden/concurrency/io/io_op__a_given_up_tls_connect_frees_its_thread.silt +++ b/tests/golden/concurrency/io/io_op__a_given_up_tls_connect_frees_its_thread.silt @@ -26,6 +26,6 @@ fn main() { give_up(tcp.local_port(listener), 70) match io.read_file("io_op__a_given_up_tls_connect_frees_its_thread.silt") { Ok(text) -> println("read the file: {string.length(text) > 0}") - Err(e) -> println("read_file: {e.message()}") + Err(e) -> println("read_file: {Error.message(e)}") } } diff --git a/tests/golden/concurrency/io/stage7_c5__a_cancelled_server_does_not_keep_its_test_test.silt b/tests/golden/concurrency/io/stage7_c5__a_cancelled_server_does_not_keep_its_test_test.silt index cd3bdaacc..8d9480f81 100644 --- a/tests/golden/concurrency/io/stage7_c5__a_cancelled_server_does_not_keep_its_test_test.silt +++ b/tests/golden/concurrency/io/stage7_c5__a_cancelled_server_does_not_keep_its_test_test.silt @@ -15,7 +15,7 @@ import test fn get(url) { match http.get(url) { Ok(r) -> r.status - Err(e) -> panic(e.message()) + Err(e) -> panic(Error.message(e)) } } diff --git a/tests/golden/concurrency/io/stage7_c5__a_cancelled_server_does_not_keep_the_program.silt b/tests/golden/concurrency/io/stage7_c5__a_cancelled_server_does_not_keep_the_program.silt index 54dd78ad7..d21783b01 100644 --- a/tests/golden/concurrency/io/stage7_c5__a_cancelled_server_does_not_keep_the_program.silt +++ b/tests/golden/concurrency/io/stage7_c5__a_cancelled_server_does_not_keep_the_program.silt @@ -13,7 +13,7 @@ import tcp fn get(url) { match http.get(url) { Ok(r) -> "status {r.status}" - Err(e) -> "error {e.message()}" + Err(e) -> "error {Error.message(e)}" } } diff --git a/tests/golden/concurrency/io/stage7_c6__a_listener_is_served_again_at_once.silt b/tests/golden/concurrency/io/stage7_c6__a_listener_is_served_again_at_once.silt index 7e50bec40..48709188a 100644 --- a/tests/golden/concurrency/io/stage7_c6__a_listener_is_served_again_at_once.silt +++ b/tests/golden/concurrency/io/stage7_c6__a_listener_is_served_again_at_once.silt @@ -27,7 +27,7 @@ fn main() { } let answer = match http.get(url) { Ok(r) -> text(r.body) - Err(e) -> e.message() + Err(e) -> Error.message(e) } task.cancel(server) match answer == "round {round}" { diff --git a/tests/golden/concurrency/io/stage7_c6__a_listener_is_served_by_one_server.silt b/tests/golden/concurrency/io/stage7_c6__a_listener_is_served_by_one_server.silt index d98c704ea..f4866f848 100644 --- a/tests/golden/concurrency/io/stage7_c6__a_listener_is_served_by_one_server.silt +++ b/tests/golden/concurrency/io/stage7_c6__a_listener_is_served_by_one_server.silt @@ -24,7 +24,7 @@ fn main() { -- The server serves when it has answered. match http.get("http://127.0.0.1:{tcp.local_port(listener)}/") { Ok(r) -> println("{r.status} {text(r.body)}") - Err(e) -> println("error: {e.message()}") + Err(e) -> println("error: {Error.message(e)}") } http.serve(listener) { _req -> http.Response { status: 200, body: bytes.from_string("second"), headers: #{} } } } diff --git a/tests/golden/concurrency/io/stage7_c6__a_served_listener_is_its_servers_alone.silt b/tests/golden/concurrency/io/stage7_c6__a_served_listener_is_its_servers_alone.silt index bec05770f..3b77398b7 100644 --- a/tests/golden/concurrency/io/stage7_c6__a_served_listener_is_its_servers_alone.silt +++ b/tests/golden/concurrency/io/stage7_c6__a_served_listener_is_its_servers_alone.silt @@ -20,7 +20,7 @@ fn text(body: Bytes) -> String { fn get(url) { match http.get(url) { Ok(r) -> "{r.status} {text(r.body)}" - Err(e) -> "error: {e.message()}" + Err(e) -> "error: {Error.message(e)}" } } @@ -36,7 +36,7 @@ fn main() { let refused = 1..100 |> list.map { _ -> match tcp.accept(listener) { Ok(_) -> "a connection" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } println(refused |> list.unique) @@ -52,9 +52,9 @@ fn main() { match tcp.accept(listener) { Ok(conn) -> match tcp.read_exact(conn, 5) { Ok(hello) -> println("accepted a client that sent {bytes.length(hello)} bytes") - Err(e) -> println("accepted a connection that says nothing: {e.message()}") + Err(e) -> println("accepted a connection that says nothing: {Error.message(e)}") } - Err(e) -> println("accept: {e.message()}") + Err(e) -> println("accept: {Error.message(e)}") } let _ = task.join(client) diff --git a/tests/golden/concurrency/io/stage7_c6__a_server_takes_the_listener_from_an_accept_that_waits.silt b/tests/golden/concurrency/io/stage7_c6__a_server_takes_the_listener_from_an_accept_that_waits.silt index bf747bb92..7e749f7f3 100644 --- a/tests/golden/concurrency/io/stage7_c6__a_server_takes_the_listener_from_an_accept_that_waits.silt +++ b/tests/golden/concurrency/io/stage7_c6__a_server_takes_the_listener_from_an_accept_that_waits.silt @@ -20,7 +20,7 @@ fn main() { let waiting = task.spawn { -> match tcp.accept(listener) { Ok(_) -> "a connection" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } let server = task.spawn { -> @@ -31,7 +31,7 @@ fn main() { println("the accept: {task.join(waiting)}") match http.get("http://127.0.0.1:{tcp.local_port(listener)}/") { Ok(r) -> println("the client: {r.status} {text(r.body)}") - Err(e) -> println("the client: {e.message()}") + Err(e) -> println("the client: {Error.message(e)}") } task.cancel(server) } diff --git a/tests/golden/concurrency/io/stage7_c6__an_accept_after_a_server_gets_a_client.silt b/tests/golden/concurrency/io/stage7_c6__an_accept_after_a_server_gets_a_client.silt index 0cac169d3..48c255a87 100644 --- a/tests/golden/concurrency/io/stage7_c6__an_accept_after_a_server_gets_a_client.silt +++ b/tests/golden/concurrency/io/stage7_c6__an_accept_after_a_server_gets_a_client.silt @@ -35,9 +35,9 @@ fn main() { tcp.close(conn) "a client" } - Err(e) -> "a connection that says nothing: {e.message()}" + Err(e) -> "a connection that says nothing: {Error.message(e)}" } - Err(e) -> "no connection: {e.message()}" + Err(e) -> "no connection: {Error.message(e)}" } let _ = task.join(client) match got { diff --git a/tests/golden/concurrency/io/stage7_c6__long_polls_all_enter_their_handlers.silt b/tests/golden/concurrency/io/stage7_c6__long_polls_all_enter_their_handlers.silt index e08f6a7af..28656dad7 100644 --- a/tests/golden/concurrency/io/stage7_c6__long_polls_all_enter_their_handlers.silt +++ b/tests/golden/concurrency/io/stage7_c6__long_polls_all_enter_their_handlers.silt @@ -35,7 +35,7 @@ fn main() { task.spawn { -> match http.get("http://127.0.0.1:{port}/wait") { Ok(r) -> "{r.status} {text(r.body)}" - Err(e) -> "error: {e.message()}" + Err(e) -> "error: {Error.message(e)}" } } } diff --git a/tests/golden/concurrency/io/stage7_c6__requests_in_flight_are_answered_503_when_their_server_ends.silt b/tests/golden/concurrency/io/stage7_c6__requests_in_flight_are_answered_503_when_their_server_ends.silt index d8d634643..c331b3c6b 100644 --- a/tests/golden/concurrency/io/stage7_c6__requests_in_flight_are_answered_503_when_their_server_ends.silt +++ b/tests/golden/concurrency/io/stage7_c6__requests_in_flight_are_answered_503_when_their_server_ends.silt @@ -38,7 +38,7 @@ fn main() { let get = { path -> match http.get("http://127.0.0.1:{port}{path}") { Ok(r) -> "{r.status} {text(r.body)}" - Err(e) -> "error: {e.message()}" + Err(e) -> "error: {Error.message(e)}" } } let clients = 1..5 |> list.map { _ -> task.spawn { -> get("/wait") } } diff --git a/tests/golden/concurrency/stack/stage7_v2__method_recursion_50000_deep_in_a_task.silt b/tests/golden/concurrency/stack/stage7_v2__method_recursion_50000_deep_in_a_task.silt index 7bedbe62b..1300c13ac 100644 --- a/tests/golden/concurrency/stack/stage7_v2__method_recursion_50000_deep_in_a_task.silt +++ b/tests/golden/concurrency/stack/stage7_v2__method_recursion_50000_deep_in_a_task.silt @@ -10,13 +10,13 @@ trait Countdown for Int { fn down(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).down() + _ -> 1 + Countdown.down(self - 1) } } } fn main() { - let h = task.spawn({ -> 50000.down() }) + let h = task.spawn({ -> Countdown.down(50000) }) println(task.join(h)) - println(50000.down()) + println(Countdown.down(50000)) } diff --git a/tests/golden/frontend/deep/round92_deep_expr__enum_variant_lex_compare.silt b/tests/golden/frontend/deep/round92_deep_expr__enum_variant_lex_compare.silt index 6b763ad14..9c7c01926 100644 --- a/tests/golden/frontend/deep/round92_deep_expr__enum_variant_lex_compare.silt +++ b/tests/golden/frontend/deep/round92_deep_expr__enum_variant_lex_compare.silt @@ -1,6 +1,6 @@ type T { V(Int, Int, Int) } -fn cmp_gen(x: t, y: t) -> Int where t: Compare { x.compare(y) } -fn eq_gen(x: t, y: t) -> Bool where t: Equal { x.equal(y) } +fn cmp_gen(x: t, y: t) -> Int where t: Compare { Compare.compare(x, y) } +fn eq_gen(x: t, y: t) -> Bool where t: Equal { x == y } fn main() { println(cmp_gen(V(1, 9, 9), V(2, 0, 0))) println(cmp_gen(V(1, 2, 9), V(1, 3, 0))) diff --git a/tests/golden/frontend/deep/round92_deep_expr__record_compare_first_differing_field_wins.silt b/tests/golden/frontend/deep/round92_deep_expr__record_compare_first_differing_field_wins.silt index 74193a255..44b8e2fbe 100644 --- a/tests/golden/frontend/deep/round92_deep_expr__record_compare_first_differing_field_wins.silt +++ b/tests/golden/frontend/deep/round92_deep_expr__record_compare_first_differing_field_wins.silt @@ -1,5 +1,5 @@ type P { a: Int, b: Int, c: Int } -fn cmp_gen(x: t, y: t) -> Int where t: Compare { x.compare(y) } +fn cmp_gen(x: t, y: t) -> Int where t: Compare { Compare.compare(x, y) } fn main() { -- a decides (later fields disagree loudly) println(cmp_gen(P { a: 1, b: 9, c: 9 }, P { a: 2, b: 0, c: 0 })) diff --git a/tests/golden/frontend/deep/round92_deep_expr__wide_record_derives_semantics.silt b/tests/golden/frontend/deep/round92_deep_expr__wide_record_derives_semantics.silt index 3bbf09abb..f71f65576 100644 --- a/tests/golden/frontend/deep/round92_deep_expr__wide_record_derives_semantics.silt +++ b/tests/golden/frontend/deep/round92_deep_expr__wide_record_derives_semantics.silt @@ -82,9 +82,9 @@ type W { f78: Int, f79: Int } -fn cmp_gen(x: t, y: t) -> Int where t: Compare { x.compare(y) } -fn eq_gen(x: t, y: t) -> Bool where t: Equal { x.equal(y) } -fn show(x: t) -> String where t: Display { x.display() } +fn cmp_gen(x: t, y: t) -> Int where t: Compare { Compare.compare(x, y) } +fn eq_gen(x: t, y: t) -> Bool where t: Equal { x == y } +fn show(x: t) -> String where t: Display { "{x}" } fn main() { let lo = W { f0: 0, f1: 1, f2: 2, f3: 3, f4: 4, f5: 5, f6: 6, f7: 7, f8: 8, f9: 9, f10: 10, f11: 11, f12: 12, f13: 13, f14: 14, f15: 15, f16: 16, f17: 17, f18: 18, f19: 19, f20: 20, f21: 21, f22: 22, f23: 23, f24: 24, f25: 25, f26: 26, f27: 27, f28: 28, f29: 29, f30: 30, f31: 31, f32: 32, f33: 33, f34: 34, f35: 35, f36: 36, f37: 37, f38: 38, f39: 39, f40: 40, f41: 41, f42: 42, f43: 43, f44: 44, f45: 45, f46: 46, f47: 47, f48: 48, f49: 49, f50: 50, f51: 51, f52: 52, f53: 53, f54: 54, f55: 55, f56: 56, f57: 57, f58: 58, f59: 59, f60: 60, f61: 61, f62: 62, f63: 63, f64: 64, f65: 65, f66: 66, f67: 67, f68: 68, f69: 69, f70: 70, f71: 71, f72: 72, f73: 73, f74: 74, f75: 75, f76: 76, f77: 77, f78: 78, f79: 1000 } let hi = W { f0: 0, f1: 1, f2: 2, f3: 3, f4: 4, f5: 5, f6: 6, f7: 7, f8: 8, f9: 9, f10: 10, f11: 11, f12: 12, f13: 13, f14: 14, f15: 15, f16: 16, f17: 17, f18: 18, f19: 19, f20: 20, f21: 21, f22: 22, f23: 23, f24: 24, f25: 25, f26: 26, f27: 27, f28: 28, f29: 29, f30: 30, f31: 31, f32: 32, f33: 33, f34: 34, f35: 35, f36: 36, f37: 37, f38: 38, f39: 39, f40: 40, f41: 41, f42: 42, f43: 43, f44: 44, f45: 45, f46: 46, f47: 47, f48: 48, f49: 49, f50: 50, f51: 51, f52: 52, f53: 53, f54: 54, f55: 55, f56: 56, f57: 57, f58: 58, f59: 59, f60: 60, f61: 61, f62: 62, f63: 63, f64: 64, f65: 65, f66: 66, f67: 67, f68: 68, f69: 69, f70: 70, f71: 71, f72: 72, f73: 73, f74: 74, f75: 75, f76: 76, f77: 77, f78: 78, f79: 2000 } diff --git a/tests/golden/frontend/deep/round92_deep_expr__wide_record_display_nests_interpolation.silt b/tests/golden/frontend/deep/round92_deep_expr__wide_record_display_nests_interpolation.silt index 0ef86fab5..96cf7d97f 100644 --- a/tests/golden/frontend/deep/round92_deep_expr__wide_record_display_nests_interpolation.silt +++ b/tests/golden/frontend/deep/round92_deep_expr__wide_record_display_nests_interpolation.silt @@ -136,5 +136,5 @@ type W { fn main() { let w = W { f0: 0, f1: 1, f2: 2, f3: 3, f4: 4, f5: 5, f6: 6, f7: 7, f8: 8, f9: 9, f10: 10, f11: 11, f12: 12, f13: 13, f14: 14, f15: 15, f16: 16, f17: 17, f18: 18, f19: 19, f20: 20, f21: 21, f22: 22, f23: 23, f24: 24, f25: 25, f26: 26, f27: 27, f28: 28, f29: 29, f30: 30, f31: 31, f32: 32, f33: 33, f34: 34, f35: 35, f36: 36, f37: 37, f38: 38, f39: 39, f40: 40, f41: 41, f42: 42, f43: 43, f44: 44, f45: 45, f46: 46, f47: 47, f48: 48, f49: 49, f50: 50, f51: 51, f52: 52, f53: 53, f54: 54, f55: 55, f56: 56, f57: 57, f58: 58, f59: 59, f60: 60, f61: 61, f62: 62, f63: 63, f64: 64, f65: 65, f66: 66, f67: 67, f68: 68, f69: 69, f70: 70, f71: 71, f72: 72, f73: 73, f74: 74, f75: 75, f76: 76, f77: 77, f78: 78, f79: 79, f80: 80, f81: 81, f82: 82, f83: 83, f84: 84, f85: 85, f86: 86, f87: 87, f88: 88, f89: 89, f90: 90, f91: 91, f92: 92, f93: 93, f94: 94, f95: 95, f96: 96, f97: 97, f98: 98, f99: 99, f100: 100, f101: 101, f102: 102, f103: 103, f104: 104, f105: 105, f106: 106, f107: 107, f108: 108, f109: 109, f110: 110, f111: 111, f112: 112, f113: 113, f114: 114, f115: 115, f116: 116, f117: 117, f118: 118, f119: 119, f120: 120, f121: 121, f122: 122, f123: 123, f124: 124, f125: 125, f126: 126, f127: 127, f128: 128, f129: 129 } - println(w.display()) + println("{w}") } diff --git a/tests/golden/frontend/fmt/printer__comments_after_open_brace.formatted b/tests/golden/frontend/fmt/printer__comments_after_open_brace.formatted index 53a595f58..e0821d4c2 100644 --- a/tests/golden/frontend/fmt/printer__comments_after_open_brace.formatted +++ b/tests/golden/frontend/fmt/printer__comments_after_open_brace.formatted @@ -41,7 +41,7 @@ fn main() { -- entry point x * 2 } println( -- everything - "{p.name()} {xs} {ys}", + "{Named.name(p)} {xs} {ys}", ) let empty = [ -- nothing in it ] diff --git a/tests/golden/frontend/fmt/printer__comments_after_open_brace.silt b/tests/golden/frontend/fmt/printer__comments_after_open_brace.silt index 852b8c8b2..532f551dd 100644 --- a/tests/golden/frontend/fmt/printer__comments_after_open_brace.silt +++ b/tests/golden/frontend/fmt/printer__comments_after_open_brace.silt @@ -37,7 +37,7 @@ fn main() { -- entry point x * 2 } println( -- everything - "{p.name()} {xs} {ys}") + "{Named.name(p)} {xs} {ys}") let empty = [ -- nothing in it ] let block = { -- a block diff --git a/tests/golden/frontend/fmt/printer__smallest_int.formatted b/tests/golden/frontend/fmt/printer__smallest_int.formatted index 55138d797..1c7290585 100644 --- a/tests/golden/frontend/fmt/printer__smallest_int.formatted +++ b/tests/golden/frontend/fmt/printer__smallest_int.formatted @@ -17,10 +17,10 @@ fn main() { let b = -(-9223372036854775808) let c = -(-(-9223372036854775808)) let d = -(-0x8000000000000000) - let e = -9223372036854775808.sh() - let f = -9223372036854775808.sh() + let e = Sh.sh(-9223372036854775808) + let f = Sh.sh(-9223372036854775808) let g = -9223372036854775808 + 1 - let h = 1.sh() + let h = Sh.sh(1) let i = 1.e5 println("{a} {b} {c} {d} {e} {f} {g} {h} {i}") } diff --git a/tests/golden/frontend/fmt/printer__smallest_int.silt b/tests/golden/frontend/fmt/printer__smallest_int.silt index 42021547c..32b10bf66 100644 --- a/tests/golden/frontend/fmt/printer__smallest_int.silt +++ b/tests/golden/frontend/fmt/printer__smallest_int.silt @@ -15,10 +15,10 @@ fn main() { let b = - -9223372036854775808 let c = -(-(- 9223372036854775808)) let d = -(-0x8000000000000000) - let e = (-9223372036854775808).sh() - let f = -9223372036854775808.sh() + let e = Sh.sh(-9223372036854775808) + let f = Sh.sh(-9223372036854775808) let g = (- 9223372036854775808) + 1 - let h = (1).sh() + let h = Sh.sh(1) let i = (1).e5 println("{a} {b} {c} {d} {e} {f} {g} {h} {i}") } diff --git a/tests/golden/frontend/recovery/one_error__a_stray_character_in_a_trait.silt b/tests/golden/frontend/recovery/one_error__a_stray_character_in_a_trait.silt index 228ea3c9f..68ad77ea5 100644 --- a/tests/golden/frontend/recovery/one_error__a_stray_character_in_a_trait.silt +++ b/tests/golden/frontend/recovery/one_error__a_stray_character_in_a_trait.silt @@ -11,5 +11,5 @@ trait T for Int { } fn main() { - println("{1.m()} {2.m()}") + println("{T.m(1)} {T.m(2)}") } diff --git a/tests/golden/frontend/recovery/one_error__a_stray_character_in_an_impl_method.silt b/tests/golden/frontend/recovery/one_error__a_stray_character_in_an_impl_method.silt index afc56cde3..465baba88 100644 --- a/tests/golden/frontend/recovery/one_error__a_stray_character_in_an_impl_method.silt +++ b/tests/golden/frontend/recovery/one_error__a_stray_character_in_an_impl_method.silt @@ -11,5 +11,5 @@ trait T for Int { } fn main() { - println("{1.m()} {2.m()}") + println("{T.m(1)} {T.m(2)}") } diff --git a/tests/golden/frontend/recovery/one_error__a_trait_that_does_not_parse_is_declared.silt b/tests/golden/frontend/recovery/one_error__a_trait_that_does_not_parse_is_declared.silt index 8d9a37ea8..adc4dd3b9 100644 --- a/tests/golden/frontend/recovery/one_error__a_trait_that_does_not_parse_is_declared.silt +++ b/tests/golden/frontend/recovery/one_error__a_trait_that_does_not_parse_is_declared.silt @@ -11,5 +11,5 @@ trait T for Int { } fn main() { - println("{1.m()}") + println("{T.m(1)}") } diff --git a/tests/golden/heavy/compute/stage6_perf__method_calls.silt b/tests/golden/heavy/compute/stage6_perf__method_calls.silt index d5278edb8..6557da2d8 100644 --- a/tests/golden/heavy/compute/stage6_perf__method_calls.silt +++ b/tests/golden/heavy/compute/stage6_perf__method_calls.silt @@ -15,7 +15,7 @@ type Acc { trait Shape { fn area(self) -> Int fn double_area(self) -> Int { - self.area() * 2 + Shape.area(self) * 2 } } @@ -38,14 +38,14 @@ trait Step for Vec2 { fn walk(v: Vec2, n: Int, acc: Int) -> Int { match n { 0 -> acc - _ -> walk(v.add(Vec2 { x: 1, y: 0 }), n - 1, acc + v.area() % 7) + _ -> walk(Step.add(v, Vec2 { x: 1, y: 0 }), n - 1, acc + Shape.area(v) % 7) } } fn generic(s: a, n: Int, acc: Int) -> Int where a: Shape { match n { 0 -> acc - _ -> generic(s, n - 1, acc + s.double_area() % 5) + _ -> generic(s, n - 1, acc + Shape.double_area(s) % 5) } } diff --git a/tests/golden/heavy/compute/stage6_perf__showing_values.silt b/tests/golden/heavy/compute/stage6_perf__showing_values.silt index 6d591377a..dcd69f748 100644 --- a/tests/golden/heavy/compute/stage6_perf__showing_values.silt +++ b/tests/golden/heavy/compute/stage6_perf__showing_values.silt @@ -37,7 +37,7 @@ fn run(n: Int, acc: Int) -> Int { let s = scene(n) let a = "{s}" let b = string.from((n, Some(s.shapes), #{ "k": [n, n] })) - let c = s.shapes.display() + let c = "{s.shapes}" let d = "{n} {s.name} {Point { x: n, y: n }} {[1, 2, 3]} {Some(n)}" run(n - 1, acc + string.length(a) + string.length(b) + string.length(c) + string.length(d)) } diff --git a/tests/golden/heavy/compute/stage7_perf__expr_tree.silt b/tests/golden/heavy/compute/stage7_perf__expr_tree.silt index 79f872fe2..ce3f14196 100644 --- a/tests/golden/heavy/compute/stage7_perf__expr_tree.silt +++ b/tests/golden/heavy/compute/stage7_perf__expr_tree.silt @@ -27,9 +27,9 @@ trait Size for Expr { match self { Num(_) -> 1 Var(_) -> 1 - Add(l, r) -> 1 + l.size() + r.size() - Mul(l, r) -> 1 + l.size() + r.size() - Neg(e) -> 1 + e.size() + Add(l, r) -> 1 + Size.size(l) + Size.size(r) + Mul(l, r) -> 1 + Size.size(l) + Size.size(r) + Neg(e) -> 1 + Size.size(e) } } } @@ -84,7 +84,7 @@ fn build(depth, seed) { fn main() { let tree = build(16, 1) let small = simplify(tree) - println("{tree.size()} {small.size()}") + println("{Size.size(tree)} {Size.size(small)}") let total = loop i = 0, acc = 0 { match i >= 60 { true -> acc diff --git a/tests/golden/heavy/json/enum_decode__a_type_with_no_decoder_is_refused_whatever_the_document_holds.silt b/tests/golden/heavy/json/enum_decode__a_type_with_no_decoder_is_refused_whatever_the_document_holds.silt index d87935332..7725f6cf5 100644 --- a/tests/golden/heavy/json/enum_decode__a_type_with_no_decoder_is_refused_whatever_the_document_holds.silt +++ b/tests/golden/heavy/json/enum_decode__a_type_with_no_decoder_is_refused_whatever_the_document_holds.silt @@ -34,7 +34,7 @@ fn from_toml(text: String, type a) -> Result(a, toml.TomlError) { fn show(r: Result(a, e)) where e: Error { match r { Ok(_) -> println("ok") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/heavy/json/integration_json_parse_list_invalid_field_error.silt b/tests/golden/heavy/json/integration_json_parse_list_invalid_field_error.silt index 6b1ac83d4..835729de2 100644 --- a/tests/golden/heavy/json/integration_json_parse_list_invalid_field_error.silt +++ b/tests/golden/heavy/json/integration_json_parse_list_invalid_field_error.silt @@ -5,7 +5,7 @@ fn program() { match json.parse_list("[\{\"name\": \"Alice\", \"salary\": \"not_a_number\"\}]", Employee) { Ok(_) -> "unexpected" Err(json.TypeMismatch(expected, actual)) -> "{expected}/{actual}" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/heavy/json/integration_json_parse_list_not_array_error.silt b/tests/golden/heavy/json/integration_json_parse_list_not_array_error.silt index eaf1bf911..d83101866 100644 --- a/tests/golden/heavy/json/integration_json_parse_list_not_array_error.silt +++ b/tests/golden/heavy/json/integration_json_parse_list_not_array_error.silt @@ -5,7 +5,7 @@ fn program() { match json.parse_list("\{\"name\": \"Alice\"\}", Employee) { Ok(_) -> "unexpected" Err(json.TypeMismatch(expected, actual)) -> "{expected}/{actual}" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/heavy/json/integration_json_parse_map_non_object_input.silt b/tests/golden/heavy/json/integration_json_parse_map_non_object_input.silt index ad1a9d44c..85398d449 100644 --- a/tests/golden/heavy/json/integration_json_parse_map_non_object_input.silt +++ b/tests/golden/heavy/json/integration_json_parse_map_non_object_input.silt @@ -4,7 +4,7 @@ fn program() { match json.parse_map("[1, 2, 3]", String) { Ok(_) -> "unexpected" Err(json.TypeMismatch(expected, actual)) -> "{expected}/{actual}" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/heavy/json/integration_json_parse_map_value_type_mismatch.silt b/tests/golden/heavy/json/integration_json_parse_map_value_type_mismatch.silt index fe063397a..5a93609f9 100644 --- a/tests/golden/heavy/json/integration_json_parse_map_value_type_mismatch.silt +++ b/tests/golden/heavy/json/integration_json_parse_map_value_type_mismatch.silt @@ -4,7 +4,7 @@ fn program() { match json.parse_map("\{\"a\": \"hello\", \"b\": \"world\"\}", Int) { Ok(_) -> "unexpected" Err(json.TypeMismatch(expected, actual)) -> "{expected}/{actual}" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/heavy/json/integration_json_parse_missing_field_error.silt b/tests/golden/heavy/json/integration_json_parse_missing_field_error.silt index 9dde5e887..a14862e04 100644 --- a/tests/golden/heavy/json/integration_json_parse_missing_field_error.silt +++ b/tests/golden/heavy/json/integration_json_parse_missing_field_error.silt @@ -8,7 +8,7 @@ fn program() { match json.parse("\{\"name\": \"Alice\"\}", User) { Ok(_) -> "unexpected" Err(json.MissingField(f)) -> f - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/heavy/json/integration_json_parse_not_object_error.silt b/tests/golden/heavy/json/integration_json_parse_not_object_error.silt index 96ed87ab5..f6c633a1f 100644 --- a/tests/golden/heavy/json/integration_json_parse_not_object_error.silt +++ b/tests/golden/heavy/json/integration_json_parse_not_object_error.silt @@ -5,7 +5,7 @@ fn program() { match json.parse("[1,2,3]", User) { Ok(_) -> "unexpected" Err(json.TypeMismatch(expected, actual)) -> "{expected}/{actual}" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/heavy/json/integration_json_parse_wrong_type_error.silt b/tests/golden/heavy/json/integration_json_parse_wrong_type_error.silt index 02701c60e..dacefa302 100644 --- a/tests/golden/heavy/json/integration_json_parse_wrong_type_error.silt +++ b/tests/golden/heavy/json/integration_json_parse_wrong_type_error.silt @@ -5,7 +5,7 @@ fn program() { match json.parse("\{\"name\": 42, \"age\": 30\}", User) { Ok(_) -> "unexpected" Err(json.TypeMismatch(expected, actual)) -> "{expected}/{actual}" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/heavy/json/json_value__any_document_reads_into_it.silt b/tests/golden/heavy/json/json_value__any_document_reads_into_it.silt index c5afe9d18..370aa1008 100644 --- a/tests/golden/heavy/json/json_value__any_document_reads_into_it.silt +++ b/tests/golden/heavy/json/json_value__any_document_reads_into_it.silt @@ -9,7 +9,7 @@ fn main() { println(v) println(json.stringify(v)) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println(json.parse("""{"k": 1, "k": 2}""", json.Value)) println(json.parse("7", json.Value)) diff --git a/tests/golden/heavy/json/time_text__a_year_past_9999_round_trips.silt b/tests/golden/heavy/json/time_text__a_year_past_9999_round_trips.silt index 6265676e1..24b2d7379 100644 --- a/tests/golden/heavy/json/time_text__a_year_past_9999_round_trips.silt +++ b/tests/golden/heavy/json/time_text__a_year_past_9999_round_trips.silt @@ -27,7 +27,7 @@ fn main() { print(text) println(toml.parse(text, Moment) == Ok(m)) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println(json.parse("""{"d": "12026-02-30", "dt": "12026-02-28T12:00:00"}""", Moment)) println(json.parse("""{"d": "2026-02-28", "dt": "12026-02-28T12:00:00+01:00"}""", Moment)) diff --git a/tests/golden/heavy/json/time_text__dates_and_times_round_trip_through_toml.silt b/tests/golden/heavy/json/time_text__dates_and_times_round_trip_through_toml.silt index 8c024d684..220ece440 100644 --- a/tests/golden/heavy/json/time_text__dates_and_times_round_trip_through_toml.silt +++ b/tests/golden/heavy/json/time_text__dates_and_times_round_trip_through_toml.silt @@ -35,7 +35,7 @@ fn main() { println(text) println(toml.parse(text, Moment) == Ok(m)) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match toml.stringify(f) { Ok(text) -> { @@ -43,7 +43,7 @@ fn main() { println(toml.parse(text, Moment)) println(toml.parse(text, Moment) == Ok(f)) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } let n = Nested { @@ -59,7 +59,7 @@ fn main() { println(text) println(toml.parse(text, Nested) == Ok(n)) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } let past = Day { d: time.Date { year: -1, month: 1, day: 1 } } @@ -68,6 +68,6 @@ fn main() { print(text) println(toml.parse(text, Day) == Ok(past)) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/heavy/lists/integration_builtin_display_list.silt b/tests/golden/heavy/lists/integration_builtin_display_list.silt index c30659866..e8046cc75 100644 --- a/tests/golden/heavy/lists/integration_builtin_display_list.silt +++ b/tests/golden/heavy/lists/integration_builtin_display_list.silt @@ -1,5 +1,5 @@ import io -fn program() { [1, 2, 3].display() } +fn program() { "{[1, 2, 3]}" } fn main() { println(io.inspect(program())) diff --git a/tests/golden/heavy/numbers/integration_where_clause_multi_trait_bounds_mixed.silt b/tests/golden/heavy/numbers/integration_where_clause_multi_trait_bounds_mixed.silt index 690fee798..f24e062ed 100644 --- a/tests/golden/heavy/numbers/integration_where_clause_multi_trait_bounds_mixed.silt +++ b/tests/golden/heavy/numbers/integration_where_clause_multi_trait_bounds_mixed.silt @@ -13,7 +13,7 @@ trait Display for Color { fn show_and_compare(a: t, b: u) where t: Equal + Compare, u: Display { let eq = a == a let lt = a < a - b.display() + "{b}" } fn program() { diff --git a/tests/golden/heavy/strings/integration_builtin_display_string.silt b/tests/golden/heavy/strings/integration_builtin_display_string.silt index ecdcfda63..ad05a111c 100644 --- a/tests/golden/heavy/strings/integration_builtin_display_string.silt +++ b/tests/golden/heavy/strings/integration_builtin_display_string.silt @@ -1,5 +1,6 @@ import io -fn program() { "hello".display() } +import string +fn program() { string.from("hello") } fn main() { println(io.inspect(program())) diff --git a/tests/golden/heavy/traits/integration_builtin_compare_int.silt b/tests/golden/heavy/traits/integration_builtin_compare_int.silt index 2ec8504f1..b4b042e3a 100644 --- a/tests/golden/heavy/traits/integration_builtin_compare_int.silt +++ b/tests/golden/heavy/traits/integration_builtin_compare_int.silt @@ -1,5 +1,5 @@ import io -fn program() { 3.compare(5) } +fn program() { Compare.compare(3, 5) } fn main() { println(io.inspect(program())) diff --git a/tests/golden/heavy/traits/integration_builtin_display_bool.silt b/tests/golden/heavy/traits/integration_builtin_display_bool.silt index 917ec4ade..c00cf5200 100644 --- a/tests/golden/heavy/traits/integration_builtin_display_bool.silt +++ b/tests/golden/heavy/traits/integration_builtin_display_bool.silt @@ -1,5 +1,5 @@ import io -fn program() { true.display() } +fn program() { "{true}" } fn main() { println(io.inspect(program())) diff --git a/tests/golden/heavy/traits/integration_builtin_display_int.silt b/tests/golden/heavy/traits/integration_builtin_display_int.silt index dc2288ed1..75f6efbb6 100644 --- a/tests/golden/heavy/traits/integration_builtin_display_int.silt +++ b/tests/golden/heavy/traits/integration_builtin_display_int.silt @@ -1,5 +1,5 @@ import io -fn program() { 42.display() } +fn program() { "{42}" } fn main() { println(io.inspect(program())) diff --git a/tests/golden/heavy/traits/integration_builtin_equal_int.silt b/tests/golden/heavy/traits/integration_builtin_equal_int.silt index e14dae51b..f46a7862f 100644 --- a/tests/golden/heavy/traits/integration_builtin_equal_int.silt +++ b/tests/golden/heavy/traits/integration_builtin_equal_int.silt @@ -1,5 +1,5 @@ import io -fn program() { 42.equal(42) } +fn program() { 42 == 42 } fn main() { println(io.inspect(program())) diff --git a/tests/golden/heavy/traits/integration_enum_and_trait.silt b/tests/golden/heavy/traits/integration_enum_and_trait.silt index 2bf06628d..0da2850eb 100644 --- a/tests/golden/heavy/traits/integration_enum_and_trait.silt +++ b/tests/golden/heavy/traits/integration_enum_and_trait.silt @@ -24,6 +24,6 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] shapes - |> list.map { s -> (s.display(), area(s)) } + |> list.map { s -> ("{s}", area(s)) } |> list.each { pair -> println("{pair}") } } diff --git a/tests/golden/heavy/traits/integration_self_type_in_trait.silt b/tests/golden/heavy/traits/integration_self_type_in_trait.silt index 9573185d7..6d404e4f3 100644 --- a/tests/golden/heavy/traits/integration_self_type_in_trait.silt +++ b/tests/golden/heavy/traits/integration_self_type_in_trait.silt @@ -12,7 +12,7 @@ trait Monoid for Int { fn program() { let x = Int.empty() - let y = Int.combine(3, 4) + let y = Monoid.combine(3, 4) x + y } diff --git a/tests/golden/heavy/traits/integration_where_clause_with_display.silt b/tests/golden/heavy/traits/integration_where_clause_with_display.silt index 75a2aa1cd..f70d87101 100644 --- a/tests/golden/heavy/traits/integration_where_clause_with_display.silt +++ b/tests/golden/heavy/traits/integration_where_clause_with_display.silt @@ -11,7 +11,7 @@ trait Display for Shape { } fn show(x: a) where a: Display { - x.display() + "{x}" } fn program() { diff --git a/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__bytes_to_hex_lowercase.silt b/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__bytes_to_hex_lowercase.silt index 221bbece0..825a40b14 100644 --- a/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__bytes_to_hex_lowercase.silt +++ b/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__bytes_to_hex_lowercase.silt @@ -2,6 +2,6 @@ import bytes fn main() { match bytes.from_hex("deadbeefABCDEF") { Ok(b) -> println(bytes.to_hex(b)) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__lowercase_table.silt b/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__lowercase_table.silt index 65187ec37..8801ba3dc 100644 --- a/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__lowercase_table.silt +++ b/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__lowercase_table.silt @@ -5,7 +5,7 @@ fn main() { list.each(digits) { d -> match bytes.from_hex("0{d}") { Ok(b) -> println(bytes.to_hex(b)) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } } diff --git a/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__uppercase_table.silt b/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__uppercase_table.silt index c9c827abc..b8a0827db 100644 --- a/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__uppercase_table.silt +++ b/tests/golden/lang/builtins/builtin_nibble_to_hex_helper__uppercase_table.silt @@ -7,9 +7,9 @@ fn main() { match bytes.from_hex("0{d}") { Ok(b) -> match bytes.to_string(b) { Ok(s) -> println(encoding.form_encode([("k", s)])) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } } diff --git a/tests/golden/lang/callables/fn_params__destructuring_patterns.silt b/tests/golden/lang/callables/fn_params__destructuring_patterns.silt index b59aaa5ac..1ee0329d6 100644 --- a/tests/golden/lang/callables/fn_params__destructuring_patterns.silt +++ b/tests/golden/lang/callables/fn_params__destructuring_patterns.silt @@ -30,5 +30,5 @@ fn main() { println(g(P { x: 1, y: 2 })) println(h((5, 6))) println(k(Wrap(4), P { x: 1, y: 0 })) - println(P { x: 1, y: 2 }.sum((10, 20))) + println(Sum.sum(P { x: 1, y: 2 }, (10, 20))) } diff --git a/tests/golden/lang/callables/pipe__into_a_method_call.silt b/tests/golden/lang/callables/pipe__into_a_method_call.silt index 15662d283..eee737ff6 100644 --- a/tests/golden/lang/callables/pipe__into_a_method_call.silt +++ b/tests/golden/lang/callables/pipe__into_a_method_call.silt @@ -8,9 +8,9 @@ trait Adder for Int { fn add(self, x: Int) -> Int { self + x } } type Opt { Wrap(Int) } fn main() { let a = Acc { base: 100 } - println(5 |> a.add()) - println(5 |> a.add) - println(5 |> 3.add()) + println(Adder.add(a, 5)) + println(Adder.add(a, 5)) + println(Adder.add(3, 5)) println(5 |> Wrap) println(5 |> Wrap()) println([1, 2] |> list.map({ x -> x + 1 })) diff --git a/tests/golden/lang/collections/range_is_a_list.silt b/tests/golden/lang/collections/range_is_a_list.silt index acd67f3c1..85b51e97e 100644 --- a/tests/golden/lang/collections/range_is_a_list.silt +++ b/tests/golden/lang/collections/range_is_a_list.silt @@ -27,7 +27,7 @@ fn main() { println("") println("{1..3} and {(1..3, 5..4)}") println(string.from(1..3)) - println((1..3).display()) + println("{1..3}") println(io.inspect(1..3)) println(io.inspect(Span { name: "s", over: 1..3 })) println(Span { name: "s", over: 2..2 }) @@ -66,9 +66,9 @@ fn main() { println(1..3 < [1, 2, 4]) println([1, 2] < 1..3) println(2..3 > [1, 9, 9]) - println((1..3).hash() == [1, 2, 3].hash()) - println(list.tail(0..3).hash() == [1, 2, 3].hash()) - println((1..3).hash() == [1, 2, 4].hash()) + println(Hash.hash(1..3) == Hash.hash([1, 2, 3])) + println(Hash.hash(list.tail(0..3)) == Hash.hash([1, 2, 3])) + println(Hash.hash(1..3) == Hash.hash([1, 2, 4])) println(set.length(#[1..3, [1, 2, 3], list.tail(0..3)])) println(map.get(#{[1, 2, 3]: "found"}, 1..3)) println(list.sort([2..3, [1, 5], 1..4, []])) diff --git a/tests/golden/lang/collections/range_of_many_holds_no_element.silt b/tests/golden/lang/collections/range_of_many_holds_no_element.silt index c8a316ae8..7191c98eb 100644 --- a/tests/golden/lang/collections/range_of_many_holds_no_element.silt +++ b/tests/golden/lang/collections/range_of_many_holds_no_element.silt @@ -23,8 +23,8 @@ fn main() { println(big == big) println(big == list.tail(big)) println(big < list.tail(big)) - println(big.hash() == (1..9223372036854775807).hash()) - println(big.hash() == list.tail(big).hash()) + println(Hash.hash(big) == Hash.hash(1..9223372036854775807)) + println(Hash.hash(big) == Hash.hash(list.tail(big))) match big { [a, b, ..rest] -> println("{a}, {b}, then {list.length(rest)} more") _ -> println("no match") diff --git a/tests/golden/lang/collections/range_too_long_to_write_out.silt b/tests/golden/lang/collections/range_too_long_to_write_out.silt index 5b755e105..920b761ae 100644 --- a/tests/golden/lang/collections/range_too_long_to_write_out.silt +++ b/tests/golden/lang/collections/range_too_long_to_write_out.silt @@ -40,7 +40,7 @@ fn test_string_from() { } fn test_display_method() { - let _ = long().display() + let _ = "{long()}" } fn test_inspect() { diff --git a/tests/golden/lang/collections/range_too_long_to_write_out.stderr b/tests/golden/lang/collections/range_too_long_to_write_out.stderr index 18833dbe0..e946e675a 100644 --- a/tests/golden/lang/collections/range_too_long_to_write_out.stderr +++ b/tests/golden/lang/collections/range_too_long_to_write_out.stderr @@ -27,8 +27,8 @@ error[runtime]: range 0..10000000 has 10000001 elements; materializing more than 10000000 is not allowed --> range_too_long_to_write_out.silt:43:11 | - 43 | let _ = long().display() - | ^^^^^^^^^^^^^^^^ range 0..10000000 has 10000001 elements; materializing more than 10000000 is not allowed + 43 | let _ = "{long()}" + | ^^^^^^^^^^ range 0..10000000 has 10000001 elements; materializing more than 10000000 is not allowed FAIL range_too_long_to_write_out.silt::test_inspect error[runtime]: range 0..10000000 has 10000001 elements; materializing more than 10000000 is not allowed --> range_too_long_to_write_out.silt:47:11 diff --git a/tests/golden/lang/collections/sort_with__a_failing_comparison_fails_the_sort.silt b/tests/golden/lang/collections/sort_with__a_failing_comparison_fails_the_sort.silt index e4960c868..7913941fe 100644 --- a/tests/golden/lang/collections/sort_with__a_failing_comparison_fails_the_sort.silt +++ b/tests/golden/lang/collections/sort_with__a_failing_comparison_fails_the_sort.silt @@ -14,7 +14,7 @@ fn main() { }) let sorted = list.sort_with([4, 2, 3, 1]) { a, b -> match channel.receive(ch) { - Some(_) -> a.compare(b) + Some(_) -> Compare.compare(a, b) None -> 0 } } @@ -23,7 +23,7 @@ fn main() { let _ = list.sort_with([1, 3, 2]) { a, b -> match a == 3 || b == 3 { true -> panic("no order for 3") - false -> a.compare(b) + false -> Compare.compare(a, b) } } } diff --git a/tests/golden/lang/collections/sort_with__orders_by_the_comparison_and_is_stable.silt b/tests/golden/lang/collections/sort_with__orders_by_the_comparison_and_is_stable.silt index da4ca6268..1365bda46 100644 --- a/tests/golden/lang/collections/sort_with__orders_by_the_comparison_and_is_stable.silt +++ b/tests/golden/lang/collections/sort_with__orders_by_the_comparison_and_is_stable.silt @@ -7,20 +7,20 @@ import list fn by_key(a: (Int, Int), b: (Int, Int)) -> Int { let (x, _) = a let (y, _) = b - x.compare(y) + Compare.compare(x, y) } fn main() { - println(list.sort_with([]) { a, b -> a.compare(b) }) - println(list.sort_with([5]) { a, b -> a.compare(b) }) - println(list.sort_with([5, 3, 9, 1, 7]) { a, b -> a.compare(b) }) - println(list.sort_with([5, 3, 9, 1, 7]) { a, b -> b.compare(a) }) + println(list.sort_with([]) { a, b -> Compare.compare(a, b) }) + println(list.sort_with([5]) { a, b -> Compare.compare(a, b) }) + println(list.sort_with([5, 3, 9, 1, 7]) { a, b -> Compare.compare(a, b) }) + println(list.sort_with([5, 3, 9, 1, 7]) { a, b -> Compare.compare(b, a) }) -- Any Int counts, not only -1, 0 and 1. - println(list.sort_with([2, 1, 3]) { a, b -> a.compare(b) * 1000000 }) + println(list.sort_with([2, 1, 3]) { a, b -> Compare.compare(a, b) * 1000000 }) -- All equal: the order of the list. println(list.sort_with(["c", "a", "b"]) { _, _ -> 0 }) -- A range. - println(list.sort_with(1..6) { a, b -> b.compare(a) }) + println(list.sort_with(1..6) { a, b -> Compare.compare(b, a) }) -- Every length from 0 to 40, keys with many ties: the same as sort_by. let lengths = 0..40 let all_same = lengths |> list.all { n -> diff --git a/tests/golden/lang/compiler/selection__field_holding_a_function_is_called.silt b/tests/golden/lang/compiler/selection__field_holding_a_function_is_called.silt index 24ce3c2d3..4db63a1eb 100644 --- a/tests/golden/lang/compiler/selection__field_holding_a_function_is_called.silt +++ b/tests/golden/lang/compiler/selection__field_holding_a_function_is_called.silt @@ -15,7 +15,7 @@ fn tail(r: Holder, n: Int, acc: Int) -> Int { fn main() { let h = Holder { run: { x -> x + 1 }, name: "h" } println(h.run(1)) - println(h.describe()) + println(Describe.describe(h)) let r = {run: { x -> x * 2 }, inner: {go: { s -> "go {s}" }}} println(r.run(4)) println(r.inner.go("on")) diff --git a/tests/golden/lang/compiler/selection__impl_method_recursion_is_a_tail_call.silt b/tests/golden/lang/compiler/selection__impl_method_recursion_is_a_tail_call.silt index 4250e6197..36030c983 100644 --- a/tests/golden/lang/compiler/selection__impl_method_recursion_is_a_tail_call.silt +++ b/tests/golden/lang/compiler/selection__impl_method_recursion_is_a_tail_call.silt @@ -9,7 +9,7 @@ trait Down for Counter { fn down(self, k: Int) -> Int { match k { 0 -> self.n - _ -> self.down(k - 1) + _ -> Down.down(self, k - 1) } } } @@ -18,7 +18,7 @@ trait Ping for Counter { fn ping(self, k: Int) -> String { match k { 0 -> "counter {self.n}" - _ -> Other { n: self.n }.ping(k - 1) + _ -> Ping.ping(Other { n: self.n }, k - 1) } } } @@ -30,8 +30,8 @@ trait Ping for Other { } } } -fn hop(c: Counter, k: Int) -> String { c.ping(k) } +fn hop(c: Counter, k: Int) -> String { Ping.ping(c, k) } fn main() { - println(Counter { n: 7 }.down(1000000)) - println(Counter { n: 0 }.ping(1000001)) + println(Down.down(Counter { n: 7 }, 1000000)) + println(Ping.ping(Counter { n: 0 }, 1000001)) } diff --git a/tests/golden/lang/compiler/selection__method_found_at_run_time_is_a_tail_call.silt b/tests/golden/lang/compiler/selection__method_found_at_run_time_is_a_tail_call.silt index db7f548c0..7399a1920 100644 --- a/tests/golden/lang/compiler/selection__method_found_at_run_time_is_a_tail_call.silt +++ b/tests/golden/lang/compiler/selection__method_found_at_run_time_is_a_tail_call.silt @@ -11,35 +11,35 @@ trait Walk { fn base(self) -> Int fn walk(self, k: Int, acc: Int) -> Int { match k { - 0 -> acc + self.base() - _ -> self.walk(k - 1, acc + 1) + 0 -> acc + Walk.base(self) + _ -> Walk.walk(self, k - 1, acc + 1) } } - fn show(self) -> String { self.base().display() } + fn show(self) -> String { "{Walk.base(self)}" } } trait Walk for C { fn base(self) -> Int { self.n } } trait Walk for Int { fn base(self) -> Int { self } } fn go(x: a, k: Int) -> Int where a: Walk { match k { - 0 -> x.base() + 0 -> Walk.base(x) _ -> go(x, k - 1) } } -fn last(x: a) -> Int where a: Walk { x.walk(1000000, 0) } +fn last(x: a) -> Int where a: Walk { Walk.walk(x, 1000000, 0) } trait Hop { fn hop(self, k: Int) -> Int } trait Hop for C { fn hop(self, k: Int) -> Int { bounce(self, k) } } fn bounce(x: a, k: Int) -> Int where a: Hop { match k { 0 -> 42 - _ -> x.hop(k - 1) + _ -> Hop.hop(x, k - 1) } } -fn shown(x: a) -> String where a: Display { x.display() } +fn shown(x: a) -> String where a: Display { "{x}" } fn main() { - println(C { n: 5 }.walk(1000000, 0)) + println(Walk.walk(C { n: 5 }, 1000000, 0)) println(last(7)) println(go(C { n: 3 }, 1000000)) - println(C { n: 9 }.show()) + println(Walk.show(C { n: 9 })) println(shown([1, 2])) println(shown(C { n: 1 })) println(bounce(C { n: 1 }, 1000000)) diff --git a/tests/golden/lang/compiler/selection__method_of_a_bounded_variable_and_of_a_builtin_type.silt b/tests/golden/lang/compiler/selection__method_of_a_bounded_variable_and_of_a_builtin_type.silt index d3846fd15..b84d6c8c6 100644 --- a/tests/golden/lang/compiler/selection__method_of_a_bounded_variable_and_of_a_builtin_type.silt +++ b/tests/golden/lang/compiler/selection__method_of_a_bounded_variable_and_of_a_builtin_type.silt @@ -6,8 +6,8 @@ type Cat { name: String } type Dog { name: String } trait Speak { fn word(self) -> String - fn twice(self) -> String { "{self.word()} {self.word()}" } - fn loud(self) -> String { "{self.twice()}!" } + fn twice(self) -> String { "{Speak.word(self)} {Speak.word(self)}" } + fn loud(self) -> String { "{Speak.twice(self)}!" } } trait Speak for Cat { fn word(self) -> String { "meow" } } trait Speak for Dog { @@ -15,19 +15,19 @@ trait Speak for Dog { fn loud(self) -> String { "WOOF" } } trait Speak for Int { fn word(self) -> String { "{self}" } } -fn all(x: a) -> String where a: Speak { "{x.word()} / {x.twice()} / {x.loud()}" } +fn all(x: a) -> String where a: Speak { "{Speak.word(x)} / {Speak.twice(x)} / {Speak.loud(x)}" } fn main() { println(all(Cat { name: "c" })) println(all(Dog { name: "d" })) println(all(7)) - println(Cat { name: "c" }.loud()) - println(Dog { name: "d" }.loud()) - println(Dog { name: "d" }.twice()) - println(Cat.twice(Cat { name: "c" })) - println(3.display()) - println([1, 2].display()) - println(Int.display(5)) - println(Cat { name: "c" }.equal(Cat { name: "c" })) - println((1, "a").compare((1, "b"))) - println(Some(2).hash() == Some(2).hash()) + println(Speak.loud(Cat { name: "c" })) + println(Speak.loud(Dog { name: "d" })) + println(Speak.twice(Dog { name: "d" })) + println(Speak.twice(Cat { name: "c" })) + println("{3}") + println("{[1, 2]}") + println("{5}") + println(Cat { name: "c" } == Cat { name: "c" }) + println(Compare.compare((1, "a"), (1, "b"))) + println(Hash.hash(Some(2)) == Hash.hash(Some(2))) } diff --git a/tests/golden/lang/compiler/wave1_compiler__c1_other_positions.silt b/tests/golden/lang/compiler/wave1_compiler__c1_other_positions.silt index a5d5a00eb..9546c5997 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c1_other_positions.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c1_other_positions.silt @@ -41,7 +41,7 @@ fn main() { 5 -> 50 _ -> 0 }) - println(3.scale(match x { + println(Scale.scale(3, match x { 5 -> 10 _ -> 0 })) diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_aliases.silt b/tests/golden/lang/compiler/wave1_compiler__c4_aliases.silt index 014ff5ae3..ce76cb601 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_aliases.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_aliases.silt @@ -16,10 +16,10 @@ fn main() { let raw = "\{\"title\": \"hi\", \"tags\": [\"a\", \"b\"], \"n\": 3, \"pair\": [1, 2]\}" match json.parse(raw, Post) { Ok(p) -> println("ok: {p.title} {p.tags} {p.n + 1} {p.pair}") - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } match toml.parse("title = \"hi\"\ntags = [\"a\", \"b\"]\nn = 3\npair = [1, 2]\n", Post) { Ok(p) -> println("ok: {p.title} {p.tags} {p.n + 1} {p.pair}") - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_enum_field_run.silt b/tests/golden/lang/compiler/wave1_compiler__c4_enum_field_run.silt index 7b2e15d2b..113d18a02 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_enum_field_run.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_enum_field_run.silt @@ -8,6 +8,6 @@ type Pixel { x: Int, c: Color } fn main() { match toml.parse("x = 1\nc = \"Red\"\n", Pixel) { Ok(v) -> println("{v.x} {v.c}") - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_generic_record_check.silt b/tests/golden/lang/compiler/wave1_compiler__c4_generic_record_check.silt index 9c7447b6b..12585eb17 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_generic_record_check.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_generic_record_check.silt @@ -12,6 +12,6 @@ fn main() { let r: Result(Wrap(Int), json.JsonError) = json.parse("\{\"value\": \"x\"\}", Wrap) match r { Ok(w) -> println(w.value + 1) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_generic_record_run.silt b/tests/golden/lang/compiler/wave1_compiler__c4_generic_record_run.silt index 9b53a8fae..53b59b6bd 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_generic_record_run.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_generic_record_run.silt @@ -11,6 +11,6 @@ fn main() { let r: Result(Wrap(Int), json.JsonError) = json.parse("\{\"value\": \"x\"\}", Wrap) match r { Ok(w) -> println(w.value + 1) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_json_map_tuple.silt b/tests/golden/lang/compiler/wave1_compiler__c4_json_map_tuple.silt index 401ff3c47..d45910b40 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_json_map_tuple.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_json_map_tuple.silt @@ -13,6 +13,6 @@ fn main() { println(s) println(v.o) } - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_json_wrong_shape.silt b/tests/golden/lang/compiler/wave1_compiler__c4_json_wrong_shape.silt index 31046d422..bce9c6aa8 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_json_wrong_shape.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_json_wrong_shape.silt @@ -9,14 +9,14 @@ fn main() { println(v) println(map.length(v.m)) } - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } match json.parse("\{\"m\": \{\"a\": \"one\"\}, \"t\": [1, 2]\}", M) { Ok(v) -> println(v) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } match json.parse("\{\"m\": \{\"a\": 1\}, \"t\": [1, 2, 3]\}", M) { Ok(v) -> println(v) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_nested_check.silt b/tests/golden/lang/compiler/wave1_compiler__c4_nested_check.silt index b3024ce62..c8d7b8bef 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_nested_check.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_nested_check.silt @@ -14,6 +14,6 @@ type Outer { inners: List(Inner) } fn main() { match json.parse_list("[]", Outer) { Ok(v) -> println(v) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_nested_run.silt b/tests/golden/lang/compiler/wave1_compiler__c4_nested_run.silt index b75f4b8c0..2f3b30c53 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_nested_run.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_nested_run.silt @@ -13,6 +13,6 @@ type Outer { inners: List(Inner) } fn main() { match json.parse_list("[]", Outer) { Ok(v) -> println(v) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_piped_check.silt b/tests/golden/lang/compiler/wave1_compiler__c4_piped_check.silt index 3508a16d5..eac2743fb 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_piped_check.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_piped_check.silt @@ -13,6 +13,6 @@ fn main() { let r = "\{\"items\": \"oops\"\}" |> json.parse(Bag) match r { Ok(v) -> println(v) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_piped_run.silt b/tests/golden/lang/compiler/wave1_compiler__c4_piped_run.silt index e6ffe2d5d..0aa4b1997 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_piped_run.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_piped_run.silt @@ -12,6 +12,6 @@ fn main() { let r = "\{\"items\": \"oops\"\}" |> json.parse(Bag) match r { Ok(v) -> println(v) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_set_field_check.silt b/tests/golden/lang/compiler/wave1_compiler__c4_set_field_check.silt index aaa30e805..f23a63ef6 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_set_field_check.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_set_field_check.silt @@ -12,6 +12,6 @@ type Bag { name: String, items: Set(Int) } fn main() { match json.parse("\{\"name\": \"b\", \"items\": \"oops\"\}", Bag) { Ok(v) -> println(v.name) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_set_field_run.silt b/tests/golden/lang/compiler/wave1_compiler__c4_set_field_run.silt index 313bd6390..261f9c0d6 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_set_field_run.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_set_field_run.silt @@ -11,6 +11,6 @@ type Bag { name: String, items: Set(Int) } fn main() { match json.parse("\{\"name\": \"b\", \"items\": \"oops\"\}", Bag) { Ok(v) -> println(v.name) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_toml_map_tuple.silt b/tests/golden/lang/compiler/wave1_compiler__c4_toml_map_tuple.silt index afe888da0..0163a66be 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_toml_map_tuple.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_toml_map_tuple.silt @@ -11,10 +11,10 @@ fn main() { println(n + 1) println(s) } - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } match toml.parse("m = \"oops\"\nt = \"also\"\n", M) { Ok(v) -> println(v) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c4_type_parameter.silt b/tests/golden/lang/compiler/wave1_compiler__c4_type_parameter.silt index 7b7f7d972..75795b3a4 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c4_type_parameter.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c4_type_parameter.silt @@ -19,10 +19,10 @@ fn from_toml(text: String, type a) -> Result(a, toml.TomlError) { fn main() { match from_json("\{\"name\": \"b\", \"items\": \"oops\"\}", Bag) { Ok(v) -> println(v.name) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } match from_toml("name = \"b\"\nitems = \"oops\"\n", Bag) { Ok(v) -> println(v.name) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__c5_enum_order.silt b/tests/golden/lang/compiler/wave1_compiler__c5_enum_order.silt index df6b7b21c..7888d24a6 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c5_enum_order.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c5_enum_order.silt @@ -3,7 +3,7 @@ fn first() { } fn describe() { - Color.Green.display() + "{Color.Green}" } type Color { Red, Green } diff --git a/tests/golden/lang/compiler/wave1_compiler__c5_later_impl.silt b/tests/golden/lang/compiler/wave1_compiler__c5_later_impl.silt index 3a17f9a9c..c60222c83 100644 --- a/tests/golden/lang/compiler/wave1_compiler__c5_later_impl.silt +++ b/tests/golden/lang/compiler/wave1_compiler__c5_later_impl.silt @@ -1,6 +1,7 @@ +import string type Money { cents: Int } -let shown = Money { cents: 5 }.display() +let shown = string.from(Money { cents: 5 }) trait Display for Money { fn display(self) -> String { diff --git a/tests/golden/lang/compiler/wave1_compiler__guard_c4_not_decoded.silt b/tests/golden/lang/compiler/wave1_compiler__guard_c4_not_decoded.silt index 845254a27..6b46b11f1 100644 --- a/tests/golden/lang/compiler/wave1_compiler__guard_c4_not_decoded.silt +++ b/tests/golden/lang/compiler/wave1_compiler__guard_c4_not_decoded.silt @@ -9,6 +9,6 @@ fn main() { println(set.length(b.items)) match json.parse("\{\"text\": \"t\"\}", Label) { Ok(v) -> println(v.text) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave1_compiler__guard_c4_supported.silt b/tests/golden/lang/compiler/wave1_compiler__guard_c4_supported.silt index 7d7257839..4f310eed6 100644 --- a/tests/golden/lang/compiler/wave1_compiler__guard_c4_supported.silt +++ b/tests/golden/lang/compiler/wave1_compiler__guard_c4_supported.silt @@ -18,15 +18,15 @@ fn main() { let raw = "\{\"name\": \"A\", \"age\": 3, \"score\": 1.5, \"active\": true, \"tags\": [\"x\"], \"home\": \{\"city\": \"B\"\}, \"seen\": \"2024-03-15\"\}" match json.parse(raw, User) { Ok(u) -> println("{u.name} {u.age} {u.score} {u.active} {u.tags} {u.nick} {u.home.city} {u.seen.year}") - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } match json.parse("\{\"name\": 1\}", User) { Ok(u) -> println(u.name) - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } let text = "name = \"A\"\nage = 3\nscore = 1.5\nactive = true\ntags = [\"x\"]\nseen = 2024-03-15\n[home]\ncity = \"B\"\n" match toml.parse(text, User) { Ok(u) -> println("{u.name} {u.age} {u.score} {u.active} {u.tags} {u.nick} {u.home.city} {u.seen.year}") - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/compiler/wave2_compiler__guard_w3_selective_ok.silt b/tests/golden/lang/compiler/wave2_compiler__guard_w3_selective_ok.silt index 64df56774..fd8ac347e 100644 --- a/tests/golden/lang/compiler/wave2_compiler__guard_w3_selective_ok.silt +++ b/tests/golden/lang/compiler/wave2_compiler__guard_w3_selective_ok.silt @@ -5,10 +5,10 @@ type Point { x: Int, y: Int } fn main() { match parse("""{"x": 1, "y": 2}""", Point) { Ok(p) -> println(p.x + p.y) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match parse_list("""[{"x": 3, "y": 4}]""", Point) { Ok(ps) -> println(ps) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/compiler/wave2_compiler__guard_w6_lambdas.silt b/tests/golden/lang/compiler/wave2_compiler__guard_w6_lambdas.silt index f1efeb739..8d10311d2 100644 --- a/tests/golden/lang/compiler/wave2_compiler__guard_w6_lambdas.silt +++ b/tests/golden/lang/compiler/wave2_compiler__guard_w6_lambdas.silt @@ -7,7 +7,7 @@ let tl = { x -> x + 1 } fn main() { let f = { x -> x * 3 } - println(f.baz()) - println(tl.baz()) + println(Baz.baz(f)) + println(Baz.baz(tl)) println(list.length([1, 2, 3])) } diff --git a/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_check.silt b/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_check.silt index d6384a506..7fa22ef6b 100644 --- a/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_check.silt +++ b/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_check.silt @@ -12,6 +12,6 @@ type Bag { name: String, items: Set(Int) } fn main() { match parse("""{"name": "b", "items": [1]}""", Bag) { Ok(b) -> println(b.name) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_piped_check.silt b/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_piped_check.silt index 2c2732d4d..abe84b0ec 100644 --- a/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_piped_check.silt +++ b/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_piped_check.silt @@ -13,6 +13,6 @@ fn main() { let r = """{"name": "b", "items": [1]}""" |> parse(Bag) match r { Ok(b) -> println(b.name) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_piped_run.silt b/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_piped_run.silt index f6d52e515..5e855cd94 100644 --- a/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_piped_run.silt +++ b/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_piped_run.silt @@ -12,6 +12,6 @@ fn main() { let r = """{"name": "b", "items": [1]}""" |> parse(Bag) match r { Ok(b) -> println(b.name) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_run.silt b/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_run.silt index 5e6676a4d..eff33b226 100644 --- a/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_run.silt +++ b/tests/golden/lang/compiler/wave2_compiler__w3_selective_parse_run.silt @@ -11,6 +11,6 @@ type Bag { name: String, items: Set(Int) } fn main() { match parse("""{"name": "b", "items": [1]}""", Bag) { Ok(b) -> println(b.name) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/compiler/wave2_compiler__w4_field_named.silt b/tests/golden/lang/compiler/wave2_compiler__w4_field_named.silt index ed79fb6cb..e0e0e8ce7 100644 --- a/tests/golden/lang/compiler/wave2_compiler__w4_field_named.silt +++ b/tests/golden/lang/compiler/wave2_compiler__w4_field_named.silt @@ -19,10 +19,10 @@ fn from_toml(text: String, type a) -> Result(a, toml.TomlError) { fn main() { match from_json("""{"name": "o", "inner": {"tags": [[1]]}}""", Outer) { Ok(v) -> println(v.name) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match from_toml("name = \"o\"\n[inner]\ntags = [[1]]\n", Outer) { Ok(v) -> println(v.name) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/compiler/wave2_compiler__w6_imported_fn/main.silt b/tests/golden/lang/compiler/wave2_compiler__w6_imported_fn/main.silt index 15c4699d6..55c76a704 100644 --- a/tests/golden/lang/compiler/wave2_compiler__w6_imported_fn/main.silt +++ b/tests/golden/lang/compiler/wave2_compiler__w6_imported_fn/main.silt @@ -2,6 +2,6 @@ import util.{ triple } import util fn main() { - println(triple.baz()) + println(util.Baz.baz(triple)) println(util.triple(2)) } diff --git a/tests/golden/lang/compiler/wave2_compiler__w6_module_fn/util.silt b/tests/golden/lang/compiler/wave2_compiler__w6_module_fn/util.silt index 058d3cdfd..2cfa74a4a 100644 --- a/tests/golden/lang/compiler/wave2_compiler__w6_module_fn/util.silt +++ b/tests/golden/lang/compiler/wave2_compiler__w6_module_fn/util.silt @@ -3,4 +3,4 @@ trait Baz for Fun { fn baz(self) -> String { "baz" } } pub fn triple(x: Int) -> Int { x * 3 } -pub fn inner() -> String { triple.baz() } +pub fn inner() -> String { Baz.baz(triple) } diff --git a/tests/golden/lang/compiler/wave2_compiler__w6_named_fn.silt b/tests/golden/lang/compiler/wave2_compiler__w6_named_fn.silt index f331cd763..0d94c6af4 100644 --- a/tests/golden/lang/compiler/wave2_compiler__w6_named_fn.silt +++ b/tests/golden/lang/compiler/wave2_compiler__w6_named_fn.silt @@ -4,6 +4,6 @@ trait Baz for Fun { fn baz(self) -> String { "baz" } } fn double(x: Int) -> Int { x * 2 } fn main() { - println(double.baz()) + println(Baz.baz(double)) println(double(21)) } diff --git a/tests/golden/lang/encoding/toml_counts_the_content_of_a_json_value_as_a_level.silt b/tests/golden/lang/encoding/toml_counts_the_content_of_a_json_value_as_a_level.silt index 96a2dfa5a..560c64b3f 100644 --- a/tests/golden/lang/encoding/toml_counts_the_content_of_a_json_value_as_a_level.silt +++ b/tests/golden/lang/encoding/toml_counts_the_content_of_a_json_value_as_a_level.silt @@ -12,11 +12,11 @@ fn main() { println(string.length(json.stringify(#{"v": deep}))) match toml.stringify(#{"v": deep}) { Ok(text) -> println("written: {string.length(text)}") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } let shallow = list.fold(1..400, json.Int(1), { acc, _ -> json.Array([acc]) }) match toml.stringify(#{"v": shallow}) { Ok(text) -> println("written: {string.length(text)}") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/encoding/toml_writes_a_json_value_as_what_it_holds.silt b/tests/golden/lang/encoding/toml_writes_a_json_value_as_what_it_holds.silt index 0613264fc..186c53b8a 100644 --- a/tests/golden/lang/encoding/toml_writes_a_json_value_as_what_it_holds.silt +++ b/tests/golden/lang/encoding/toml_writes_a_json_value_as_what_it_holds.silt @@ -28,6 +28,6 @@ fn main() { println(said(toml.stringify(#{"v": json.Array([json.Null])}))) match json.parse("\{\"name\": \"silt\", \"tags\": [\"a\", \"b\"]}", json.Value) { Ok(parsed) -> println(said(toml.stringify(parsed))) - Err(e) -> println("parse: {e.message()}") + Err(e) -> println("parse: {Error.message(e)}") } } diff --git a/tests/golden/lang/errors/closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt b/tests/golden/lang/errors/closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt index 25507ecad..1762b8030 100644 --- a/tests/golden/lang/errors/closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt +++ b/tests/golden/lang/errors/closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt @@ -1,25 +1,27 @@ -- exit: 1 --- A method the language has for a type, taken as a value, is a frame --- under the method's name, as a written method is: the program wrote --- no closure there. +-- A trait's method taken as a value where the impl is found when it +-- runs is a frame under the method's name, as a written method is: the +-- program wrote no closure there. import list type Inner { n: Int, } -trait Display for Inner { - fn display(self) -> String { - "{1 / (self.n - self.n)}" +trait Div { + fn div(self) -> Int +} + +trait Div for Inner { + fn div(self) -> Int { + 1 / (self.n - self.n) } } -type Outer { - inner: Inner, - tag: Int, +fn all(xs: List(a)) -> List(Int) where a: Div { + list.map(xs, Div.div) } fn main() { - let shown = list.map([Outer { inner: Inner { n: 1 }, tag: 2 }], Outer.display) - println(shown) + println(all([Inner { n: 1 }])) } diff --git a/tests/golden/lang/errors/closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.stderr b/tests/golden/lang/errors/closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.stderr index af15c9ec4..9e3a92b16 100644 --- a/tests/golden/lang/errors/closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.stderr +++ b/tests/golden/lang/errors/closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.stderr @@ -1,10 +1,11 @@ error[runtime]: division by zero - --> closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt:13:7 + --> closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt:17:5 | - 13 | "{1 / (self.n - self.n)}" - | ^^^^^^^^^^^^^^^^^^^^^ division by zero + 17 | 1 / (self.n - self.n) + | ^^^^^^^^^^^^^^^^^^^^^ division by zero call stack: - -> Inner.display at closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt:13:7 - -> Outer.display at closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt:23:67 - -> main at closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt:23:15 + -> Inner.div at closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt:17:5 + -> Div.div at closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt:22:16 + -> all at closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt:22:3 + -> main at closure_frames__a_native_method_taken_as_a_value_is_named_after_the_method.silt:26:11 diff --git a/tests/golden/lang/errors/closure_frames__a_native_method_value_is_shown_under_the_method_s_name.silt b/tests/golden/lang/errors/closure_frames__a_native_method_value_is_shown_under_the_method_s_name.silt index 1f6237f5a..c2f82c335 100644 --- a/tests/golden/lang/errors/closure_frames__a_native_method_value_is_shown_under_the_method_s_name.silt +++ b/tests/golden/lang/errors/closure_frames__a_native_method_value_is_shown_under_the_method_s_name.silt @@ -1,4 +1,4 @@ -- cmd: repl --- stdin: Int.display\nlet f = Int.compare\nf\ntype Pt { x: Int }\nPt.display\n[Pt.equal]\n:quit\n --- A method the language has for a type, taken as a value, is shown --- under the method's name, as a written method is. +-- stdin: Compare.compare\nlet f = Hash.hash\nf\nError.message\n[Compare.compare]\n:quit\n +-- A method the language has for a type, taken as a value through its +-- trait, is shown under the method's name, as a written method is. diff --git a/tests/golden/lang/errors/closure_frames__a_native_method_value_is_shown_under_the_method_s_name.stdout b/tests/golden/lang/errors/closure_frames__a_native_method_value_is_shown_under_the_method_s_name.stdout index e6550f43a..be7fb10ca 100644 --- a/tests/golden/lang/errors/closure_frames__a_native_method_value_is_shown_under_the_method_s_name.stdout +++ b/tests/golden/lang/errors/closure_frames__a_native_method_value_is_shown_under_the_method_s_name.stdout @@ -1,5 +1,5 @@ Silt REPL (type :quit to exit, :help for commands) - - - -[] + + + +[] diff --git a/tests/golden/lang/errors/closure_frames__in_a_method_and_in_a_default_method.silt b/tests/golden/lang/errors/closure_frames__in_a_method_and_in_a_default_method.silt index 688b1cd30..41e175d41 100644 --- a/tests/golden/lang/errors/closure_frames__in_a_method_and_in_a_default_method.silt +++ b/tests/golden/lang/errors/closure_frames__in_a_method_and_in_a_default_method.silt @@ -8,7 +8,7 @@ type Half { trait Sized { fn size(self) -> Int fn twice(self) -> Int { - let double = { n -> n + self.size() } + let double = { n -> n + Sized.size(self) } double(1) + 0 } } @@ -21,5 +21,5 @@ trait Sized for Half { } fn main() { - println(Half { n: 4 }.twice()) + println(Sized.twice(Half { n: 4 })) } diff --git a/tests/golden/lang/errors/error__runtime_int_parse_error_message_dispatch.silt b/tests/golden/lang/errors/error__runtime_int_parse_error_message_dispatch.silt index f96f84401..4c73becca 100644 --- a/tests/golden/lang/errors/error__runtime_int_parse_error_message_dispatch.silt +++ b/tests/golden/lang/errors/error__runtime_int_parse_error_message_dispatch.silt @@ -2,6 +2,6 @@ import int fn main() { match int.parse("") { Ok(_) -> println("impossible") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/errors/error__type_where_clause_violation.silt b/tests/golden/lang/errors/error__type_where_clause_violation.silt index 3fb980512..27406c6df 100644 --- a/tests/golden/lang/errors/error__type_where_clause_violation.silt +++ b/tests/golden/lang/errors/error__type_where_clause_violation.silt @@ -1,7 +1,7 @@ -- cmd: check -- exit: 1 -- stderr-contains: not introduced in the function signature -fn show(x) where x: Display { x.display() } +fn show(x) where x: Display { "{x}" } fn main() { show({ -> 1 }) } diff --git a/tests/golden/lang/errors/round73f_deferred_fixes__display_equals_message_for_io_error.silt b/tests/golden/lang/errors/round73f_deferred_fixes__display_equals_message_for_io_error.silt index 9982173e3..2085e83aa 100644 --- a/tests/golden/lang/errors/round73f_deferred_fixes__display_equals_message_for_io_error.silt +++ b/tests/golden/lang/errors/round73f_deferred_fixes__display_equals_message_for_io_error.silt @@ -5,7 +5,7 @@ fn main() { Ok(_) -> () Err(e) -> { let display_form = "{e}" - let message_form = e.message() + let message_form = Error.message(e) match display_form == message_form { true -> println("EQUIV") false -> { diff --git a/tests/golden/lang/errors/round73f_deferred_fixes__display_method_equals_message_for_io_error.silt b/tests/golden/lang/errors/round73f_deferred_fixes__display_method_equals_message_for_io_error.silt index 1764dd517..c324cba63 100644 --- a/tests/golden/lang/errors/round73f_deferred_fixes__display_method_equals_message_for_io_error.silt +++ b/tests/golden/lang/errors/round73f_deferred_fixes__display_method_equals_message_for_io_error.silt @@ -4,8 +4,8 @@ fn main() { match io.read_file("nope_round74_lock_does_not_exist.txt") { Ok(_) -> () Err(e) -> { - let display_method_form = e.display() - let message_form = e.message() + let display_method_form = "{e}" + let message_form = Error.message(e) match display_method_form == message_form { true -> println("EQUIV") false -> { diff --git a/tests/golden/lang/errors/round92_tuple_index_message__named_method_keeps_generic.silt b/tests/golden/lang/errors/round92_tuple_index_message__named_method_keeps_generic.silt index 79f6aa4a3..71aea0fa0 100644 --- a/tests/golden/lang/errors/round92_tuple_index_message__named_method_keeps_generic.silt +++ b/tests/golden/lang/errors/round92_tuple_index_message__named_method_keeps_generic.silt @@ -1,6 +1,6 @@ -- cmd: check -- exit: 1 --- stderr-contains: unknown method 'frobnicate' +-- stderr-contains: type '(Int, Int)' has no field 'frobnicate' -- stderr-not-contains: tuple indexing fn main() { let t = (1, 2) diff --git a/tests/golden/lang/errors/unknown_method_suggest__list_suggests_close_match.silt b/tests/golden/lang/errors/unknown_method_suggest__list_suggests_close_match.silt deleted file mode 100644 index a2ef1b8d4..000000000 --- a/tests/golden/lang/errors/unknown_method_suggest__list_suggests_close_match.silt +++ /dev/null @@ -1,8 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown method 'dispaly' --- stderr-contains: = help: did you mean `display`? -fn main() { - let xs = [1, 2, 3] - println(xs.dispaly()) -} diff --git a/tests/golden/lang/errors/unknown_method_suggest__too_far_omits_suggestion.silt b/tests/golden/lang/errors/unknown_method_suggest__too_far_omits_suggestion.silt deleted file mode 100644 index c91d4cb2f..000000000 --- a/tests/golden/lang/errors/unknown_method_suggest__too_far_omits_suggestion.silt +++ /dev/null @@ -1,8 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown method 'qqqqqqqq_unrelated' --- stderr-not-contains: did you mean -fn main() { - let xs = [1, 2, 3] - println(xs.qqqqqqqq_unrelated()) -} diff --git a/tests/golden/lang/errors/unknown_method_suggest__tuple_suggests_close_match.silt b/tests/golden/lang/errors/unknown_method_suggest__tuple_suggests_close_match.silt deleted file mode 100644 index cdd05028e..000000000 --- a/tests/golden/lang/errors/unknown_method_suggest__tuple_suggests_close_match.silt +++ /dev/null @@ -1,8 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown method 'dispaly' on Tuple --- stderr-contains: = help: did you mean `display`? -fn main() { - let t = (1, 2) - println(t.dispaly()) -} diff --git a/tests/golden/lang/errors/wave2_sweep__chain_of_1024_method_calls_accepted.silt b/tests/golden/lang/errors/wave2_sweep__chain_of_1024_method_calls_accepted.silt index c9f03cf62..1b8b5c13c 100644 --- a/tests/golden/lang/errors/wave2_sweep__chain_of_1024_method_calls_accepted.silt +++ b/tests/golden/lang/errors/wave2_sweep__chain_of_1024_method_calls_accepted.silt @@ -6,6 +6,6 @@ trait Same for Int { } fn main() { let x = 7 - let r = x.same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same().same() + let r = x |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same |> Same.same println(r) } diff --git a/tests/golden/lang/float_display/string_from_a_whole_float.silt b/tests/golden/lang/float_display/string_from_a_whole_float.silt index 87abe8e30..c2ff05c5d 100644 --- a/tests/golden/lang/float_display/string_from_a_whole_float.silt +++ b/tests/golden/lang/float_display/string_from_a_whole_float.silt @@ -5,5 +5,5 @@ fn main() { println(string.length(string.from(1.0))) println(string.from(1.0) == "1.0") println(string.from(-12.0)) - println(4.0.display()) + println("{4.0}") } diff --git a/tests/golden/lang/floats/float_parse_rejects_non_finite.silt b/tests/golden/lang/floats/float_parse_rejects_non_finite.silt index a3317d654..b9c7ade15 100644 --- a/tests/golden/lang/floats/float_parse_rejects_non_finite.silt +++ b/tests/golden/lang/floats/float_parse_rejects_non_finite.silt @@ -7,7 +7,7 @@ fn main() { |> list.each { s -> match float.parse(s) { Ok(f) -> println("{s}: Ok({f})") - Err(e) -> println("{s}: {e.message()}") + Err(e) -> println("{s}: {Error.message(e)}") } } } diff --git a/tests/golden/lang/fs/fs_walk_stat__glob_malformed_pattern_errs.silt b/tests/golden/lang/fs/fs_walk_stat__glob_malformed_pattern_errs.silt index dd244d0ff..65a26cdda 100644 --- a/tests/golden/lang/fs/fs_walk_stat__glob_malformed_pattern_errs.silt +++ b/tests/golden/lang/fs/fs_walk_stat__glob_malformed_pattern_errs.silt @@ -4,7 +4,7 @@ fn main() { match fs.glob("src/[unterminated") { Ok(_) -> println("unexpected Ok") Err(e) -> { - let msg = e.message() + let msg = Error.message(e) println(string.starts_with(msg, "invalid input")) } } diff --git a/tests/golden/lang/fs/fs_walk_stat__stat_missing_path_errs.silt b/tests/golden/lang/fs/fs_walk_stat__stat_missing_path_errs.silt index eab63051c..d2d542a22 100644 --- a/tests/golden/lang/fs/fs_walk_stat__stat_missing_path_errs.silt +++ b/tests/golden/lang/fs/fs_walk_stat__stat_missing_path_errs.silt @@ -2,6 +2,6 @@ import fs fn main() { match fs.stat("does_not_exist") { Ok(_) -> println("unexpected Ok") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/fs/fs_walk_stat__stat_on_directory.silt b/tests/golden/lang/fs/fs_walk_stat__stat_on_directory.silt index 013e73058..31201f0a7 100644 --- a/tests/golden/lang/fs/fs_walk_stat__stat_on_directory.silt +++ b/tests/golden/lang/fs/fs_walk_stat__stat_on_directory.silt @@ -7,6 +7,6 @@ fn main() { println(s.is_symlink) println(s.size >= 0) } - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/lang/fs/fs_walk_stat__walk_missing_root_errs.silt b/tests/golden/lang/fs/fs_walk_stat__walk_missing_root_errs.silt index 0266fc101..61f891a72 100644 --- a/tests/golden/lang/fs/fs_walk_stat__walk_missing_root_errs.silt +++ b/tests/golden/lang/fs/fs_walk_stat__walk_missing_root_errs.silt @@ -2,6 +2,6 @@ import fs fn main() { match fs.walk("nope") { Ok(_) -> println("unexpected Ok") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/imports/feature__import_of_a_module_whose_feature_is_not_built.silt b/tests/golden/lang/imports/feature__import_of_a_module_whose_feature_is_not_built.silt index 539cc457c..fe5a3cfee 100644 --- a/tests/golden/lang/imports/feature__import_of_a_module_whose_feature_is_not_built.silt +++ b/tests/golden/lang/imports/feature__import_of_a_module_whose_feature_is_not_built.silt @@ -9,7 +9,7 @@ import postgres fn main() { match postgres.connect("postgres://localhost/app") { Ok(_) -> println("connected") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } let e = postgres.PostgresError.Connect("nope") println(e) diff --git a/tests/golden/lang/io/hardening__read_write_error_paths.silt b/tests/golden/lang/io/hardening__read_write_error_paths.silt index 722c15ae5..242c1630a 100644 --- a/tests/golden/lang/io/hardening__read_write_error_paths.silt +++ b/tests/golden/lang/io/hardening__read_write_error_paths.silt @@ -7,7 +7,7 @@ fn main() { println(match io.read_file("silt_test_nonexistent_file_12345.txt") { Ok(_) -> "unexpected success" Err(e) -> match { - e.message() == "" -> "empty error" + Error.message(e) == "" -> "empty error" _ -> "has error message" } }) diff --git a/tests/golden/lang/io/hardening__write_and_read_roundtrip.silt b/tests/golden/lang/io/hardening__write_and_read_roundtrip.silt index 56b002a33..a28bdf201 100644 --- a/tests/golden/lang/io/hardening__write_and_read_roundtrip.silt +++ b/tests/golden/lang/io/hardening__write_and_read_roundtrip.silt @@ -5,7 +5,7 @@ fn main() { io.write_file(path, "hello silt")? match io.read_file(path) { Ok(content) -> println(content) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } fs.remove(path) } diff --git a/tests/golden/lang/json_decode/decode_takes_no_value.silt b/tests/golden/lang/json_decode/decode_takes_no_value.silt index c61c4cf20..ceb4d44a3 100644 --- a/tests/golden/lang/json_decode/decode_takes_no_value.silt +++ b/tests/golden/lang/json_decode/decode_takes_no_value.silt @@ -1,9 +1,9 @@ -- cmd: check -- exit: 1 --- stderr-contains: unknown field or method 'decode' on type P --- `decode` takes no value of the type: it is no method of a call on a --- value (`p.decode(..)`), only of one through the type, so a program's --- own `decode` method on a value is not ambiguous with it. +-- stderr-contains: type 'P' has no field 'decode' +-- `decode` of json.Decode takes no value of the type: it is called +-- through the type. A program's own `decode` that takes one is called +-- through its trait, and a dot after a value is a field. import json type P { x: Int } @@ -15,7 +15,7 @@ trait Load for String { } fn main() { - let _ = "x".decode("y") + let _ = Load.decode("x", "y") let p = P { x: 1 } println(p.decode(json.Null)) } diff --git a/tests/golden/lang/json_encode/a_let_that_writes_a_value_needs_what_its_impl_reads.silt b/tests/golden/lang/json_encode/a_let_that_writes_a_value_needs_what_its_impl_reads.silt index a7c20f5d8..ba83706df 100644 --- a/tests/golden/lang/json_encode/a_let_that_writes_a_value_needs_what_its_impl_reads.silt +++ b/tests/golden/lang/json_encode/a_let_that_writes_a_value_needs_what_its_impl_reads.silt @@ -16,7 +16,7 @@ trait json.Encode for T { fn send(x: a) -> String where a: json.Encode { json.stringify([x]) } let s = json.stringify(T { n: 1 }) -let e = T { n: 2 }.encode() +let e = json.Encode.encode(T { n: 2 }) let g = send(T { n: 3 }) let t = toml.stringify(#{"k": T { n: 4 }}) let m = json.encode(Some(T { n: 5 })) diff --git a/tests/golden/lang/json_encode/a_program_trait_with_an_encode_method/case.stdout b/tests/golden/lang/json_encode/a_program_trait_with_an_encode_method/case.stdout new file mode 100644 index 000000000..195f10c48 --- /dev/null +++ b/tests/golden/lang/json_encode/a_program_trait_with_an_encode_method/case.stdout @@ -0,0 +1,3 @@ +t1 +t2 +Object(#{"x": Int(3)}) diff --git a/tests/golden/lang/json_encode/its_method_is_seen_where_json_is_imported/codec.silt b/tests/golden/lang/json_encode/a_program_trait_with_an_encode_method/codec.silt similarity index 90% rename from tests/golden/lang/json_encode/its_method_is_seen_where_json_is_imported/codec.silt rename to tests/golden/lang/json_encode/a_program_trait_with_an_encode_method/codec.silt index 45753dc23..496225343 100644 --- a/tests/golden/lang/json_encode/its_method_is_seen_where_json_is_imported/codec.silt +++ b/tests/golden/lang/json_encode/a_program_trait_with_an_encode_method/codec.silt @@ -13,5 +13,5 @@ trait Codec for T { } pub fn show(t: T) -> String { - t.encode() + Codec.encode(t) } diff --git a/tests/golden/lang/json_encode/a_program_trait_with_an_encode_method/main.silt b/tests/golden/lang/json_encode/a_program_trait_with_an_encode_method/main.silt new file mode 100644 index 000000000..150606c67 --- /dev/null +++ b/tests/golden/lang/json_encode/a_program_trait_with_an_encode_method/main.silt @@ -0,0 +1,10 @@ +-- A program's own trait with a method `encode` beside `json.Encode`: +-- each call names its trait, in a module that imports json too. +import codec.{ Codec, T, show } +import json + +fn main() { + println(show(T { x: 1 })) + println(Codec.encode(T { x: 2 })) + println(json.Encode.encode(T { x: 3 })) +} diff --git a/tests/golden/lang/json_encode/its_method_is_seen_after_any_import_of_json.silt b/tests/golden/lang/json_encode/its_method_is_seen_after_any_import_of_json.silt index 277657b04..0f1a616f9 100644 --- a/tests/golden/lang/json_encode/its_method_is_seen_after_any_import_of_json.silt +++ b/tests/golden/lang/json_encode/its_method_is_seen_after_any_import_of_json.silt @@ -2,12 +2,12 @@ -- visible, a selective one too, as a `pub` trait of a module is after -- `import m.{ mk }`. (Without any import of json there is no `encode`: -- its_method_needs_import_json.) -import json.{ stringify } +import json.{ stringify, Encode } type P { x: Int } fn main() { println(stringify(P { x: 1 })) - println(P { x: 1 }.encode()) - println(1.encode()) + println(Encode.encode(P { x: 1 })) + println(Encode.encode(1)) } diff --git a/tests/golden/lang/json_encode/its_method_is_seen_where_json_is_imported/main.silt b/tests/golden/lang/json_encode/its_method_is_seen_where_json_is_imported/main.silt deleted file mode 100644 index 47f99ce4c..000000000 --- a/tests/golden/lang/json_encode/its_method_is_seen_where_json_is_imported/main.silt +++ /dev/null @@ -1,15 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: ambiguous method 'encode' on type 'codec.T': provided by traits codec.Codec, json.Encode --- stderr-contains: --> main.silt:14:11 --- stderr-not-contains: --> codec.silt --- Every type with `json.Encode` has its method `encode` in a module that --- imports json, so there a method `encode` of the program's own trait is --- ambiguous. Where json is not imported (`codec`) it is the only one. -import codec.{ Codec, T, show } -import json - -fn main() { - println(show(T { x: 1 })) - println(T { x: 1 }.encode()) -} diff --git a/tests/golden/lang/json_encode/its_method_needs_import_json.silt b/tests/golden/lang/json_encode/its_method_needs_import_json.silt deleted file mode 100644 index 2f14eeead..000000000 --- a/tests/golden/lang/json_encode/its_method_needs_import_json.silt +++ /dev/null @@ -1,31 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: --> its_method_needs_import_json.silt:23:11 --- stderr-contains: --> its_method_needs_import_json.silt:24:11 --- stderr-contains: --> its_method_needs_import_json.silt:25:11 --- stderr-contains: --> its_method_needs_import_json.silt:26:11 --- stderr-contains: --> its_method_needs_import_json.silt:28:11 --- stderr-contains: --> its_method_needs_import_json.silt:29:11 --- stderr-contains: --> its_method_needs_import_json.silt:30:11 --- stderr-contains: unknown field or method 'encode' on type P --- `json.Encode` is a trait of the json module: its method `encode` is a --- value's only in a module that imports json, of a record, an enum, a --- generic record, an Option, a tuple and an Int alike. (A record's and an --- enum's were not asked for the import.) - -type P { x: Int } -type E { A, B(Int) } -type G(a) { v: a } - -fn main() { - let p = P { x: 1 } - let o: Option(Int) = Some(1) - println(p.encode()) - println(B(2).encode()) - println(A.encode()) - println(G { v: [1] }.encode()) - println(o.display()) - println(o.encode()) - println((1, 2).encode()) - println(1.encode()) -} diff --git a/tests/golden/lang/json_encode/json_encode_is_the_value_of_what_stringify_writes.silt b/tests/golden/lang/json_encode/json_encode_is_the_value_of_what_stringify_writes.silt index 66f8458d1..200c4b7a8 100644 --- a/tests/golden/lang/json_encode/json_encode_is_the_value_of_what_stringify_writes.silt +++ b/tests/golden/lang/json_encode/json_encode_is_the_value_of_what_stringify_writes.silt @@ -24,7 +24,7 @@ trait json.Encode for Pair(a) where a: json.Encode { } fn twice(x: a) -> List(json.Value) where a: json.Encode { - [x.encode(), json.encode(x)] + [json.Encode.encode(x), json.encode(x)] } fn same(x: a) -> Bool where a: json.Encode { @@ -41,13 +41,13 @@ fn main() { println(json.encode((1, "a"))) println(json.encode(P { x: 1, total: Money { cents: 5 }, tags: ["t"] })) println(json.encode(Pair { left: Money { cents: 1 }, right: Money { cents: 2 } })) - println(5.encode()) - println(Money { cents: 9 }.encode()) + println(json.Encode.encode(5)) + println(json.Encode.encode(Money { cents: 9 })) println(twice(Money { cents: 3 })) println(twice([1, 2])) println(json.stringify(json.encode(P { x: 1, total: Money { cents: 5 }, tags: [] }))) println(json.stringify(P { x: 1, total: Money { cents: 5 }, tags: [] })) println([same(1), same(1.0e21), same(-0.5), same("s"), same([Some(1), None]), same(#{"k": 1.5}), same(time.date(2026, 10, 21)), same(P { x: 1, total: Money { cents: 5 }, tags: ["a"] })]) - let f = Money.encode + let f = json.Encode.encode println(f(Money { cents: 4 })) } diff --git a/tests/golden/lang/json_encode/the_encode_method_gives_a_json_value.silt b/tests/golden/lang/json_encode/the_encode_method_gives_a_json_value.silt index 9461421ac..124d884c0 100644 --- a/tests/golden/lang/json_encode/the_encode_method_gives_a_json_value.silt +++ b/tests/golden/lang/json_encode/the_encode_method_gives_a_json_value.silt @@ -3,21 +3,21 @@ -- stderr-contains: --> the_encode_method_gives_a_json_value.silt:16:16 -- stderr-contains: --> the_encode_method_gives_a_json_value.silt:21:44 -- stderr-contains: --> the_encode_method_gives_a_json_value.silt:23:10 --- stderr-contains: unknown method 'encode' on type Fn +-- stderr-contains: has no field 'encode' -- stderr-not-contains: :17: --- `.encode()` of a value whose type has `json.Encode` is a `json.Value`, --- by a concrete type and through a bound, and a value of a type without --- the trait has no such method. (It was taken as of any type.) +-- `json.Encode.encode` of a value whose type has the trait is a +-- `json.Value`, by a concrete type and through a bound; a dot after a +-- value is a field. (It was taken as of any type.) import json type Money { cents: Int } fn main() { - let a: Int = 5.encode() - let b: json.Value = Money { cents: 1 }.encode() + let a: Int = json.Encode.encode(5) + let b: json.Value = json.Encode.encode(Money { cents: 1 }) println(b) } -fn via(x: a) -> Int where a: json.Encode { x.encode() } +fn via(x: a) -> Int where a: json.Encode { json.Encode.encode(x) } fn f() { { x -> x }.encode() } diff --git a/tests/golden/lang/limits/stage7_v1__trait_method_256_parameters.silt b/tests/golden/lang/limits/stage7_v1__trait_method_256_parameters.silt index 6910877cc..386581473 100644 --- a/tests/golden/lang/limits/stage7_v1__trait_method_256_parameters.silt +++ b/tests/golden/lang/limits/stage7_v1__trait_method_256_parameters.silt @@ -8,5 +8,5 @@ trait Tr for Int { fn go(self, p0: Int, p1: Int, p2: Int, p3: Int, p4: Int, p5: Int, p6: Int, p7: Int, p8: Int, p9: Int, p10: Int, p11: Int, p12: Int, p13: Int, p14: Int, p15: Int, p16: Int, p17: Int, p18: Int, p19: Int, p20: Int, p21: Int, p22: Int, p23: Int, p24: Int, p25: Int, p26: Int, p27: Int, p28: Int, p29: Int, p30: Int, p31: Int, p32: Int, p33: Int, p34: Int, p35: Int, p36: Int, p37: Int, p38: Int, p39: Int, p40: Int, p41: Int, p42: Int, p43: Int, p44: Int, p45: Int, p46: Int, p47: Int, p48: Int, p49: Int, p50: Int, p51: Int, p52: Int, p53: Int, p54: Int, p55: Int, p56: Int, p57: Int, p58: Int, p59: Int, p60: Int, p61: Int, p62: Int, p63: Int, p64: Int, p65: Int, p66: Int, p67: Int, p68: Int, p69: Int, p70: Int, p71: Int, p72: Int, p73: Int, p74: Int, p75: Int, p76: Int, p77: Int, p78: Int, p79: Int, p80: Int, p81: Int, p82: Int, p83: Int, p84: Int, p85: Int, p86: Int, p87: Int, p88: Int, p89: Int, p90: Int, p91: Int, p92: Int, p93: Int, p94: Int, p95: Int, p96: Int, p97: Int, p98: Int, p99: Int, p100: Int, p101: Int, p102: Int, p103: Int, p104: Int, p105: Int, p106: Int, p107: Int, p108: Int, p109: Int, p110: Int, p111: Int, p112: Int, p113: Int, p114: Int, p115: Int, p116: Int, p117: Int, p118: Int, p119: Int, p120: Int, p121: Int, p122: Int, p123: Int, p124: Int, p125: Int, p126: Int, p127: Int, p128: Int, p129: Int, p130: Int, p131: Int, p132: Int, p133: Int, p134: Int, p135: Int, p136: Int, p137: Int, p138: Int, p139: Int, p140: Int, p141: Int, p142: Int, p143: Int, p144: Int, p145: Int, p146: Int, p147: Int, p148: Int, p149: Int, p150: Int, p151: Int, p152: Int, p153: Int, p154: Int, p155: Int, p156: Int, p157: Int, p158: Int, p159: Int, p160: Int, p161: Int, p162: Int, p163: Int, p164: Int, p165: Int, p166: Int, p167: Int, p168: Int, p169: Int, p170: Int, p171: Int, p172: Int, p173: Int, p174: Int, p175: Int, p176: Int, p177: Int, p178: Int, p179: Int, p180: Int, p181: Int, p182: Int, p183: Int, p184: Int, p185: Int, p186: Int, p187: Int, p188: Int, p189: Int, p190: Int, p191: Int, p192: Int, p193: Int, p194: Int, p195: Int, p196: Int, p197: Int, p198: Int, p199: Int, p200: Int, p201: Int, p202: Int, p203: Int, p204: Int, p205: Int, p206: Int, p207: Int, p208: Int, p209: Int, p210: Int, p211: Int, p212: Int, p213: Int, p214: Int, p215: Int, p216: Int, p217: Int, p218: Int, p219: Int, p220: Int, p221: Int, p222: Int, p223: Int, p224: Int, p225: Int, p226: Int, p227: Int, p228: Int, p229: Int, p230: Int, p231: Int, p232: Int, p233: Int, p234: Int, p235: Int, p236: Int, p237: Int, p238: Int, p239: Int, p240: Int, p241: Int, p242: Int, p243: Int, p244: Int, p245: Int, p246: Int, p247: Int, p248: Int, p249: Int, p250: Int, p251: Int, p252: Int, p253: Int, p254: Int) -> Int { self + p0 + p254 * 2 } } fn main() { - println(5.go(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254)) + println(Tr.go(5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254)) } diff --git a/tests/golden/lang/modules/round94_imported_enum_variant_collision__equality_on_imported_enum_works/main.silt b/tests/golden/lang/modules/round94_imported_enum_variant_collision__equality_on_imported_enum_works/main.silt index fedd54882..a4f92ff75 100644 --- a/tests/golden/lang/modules/round94_imported_enum_variant_collision__equality_on_imported_enum_works/main.silt +++ b/tests/golden/lang/modules/round94_imported_enum_variant_collision__equality_on_imported_enum_works/main.silt @@ -6,5 +6,5 @@ fn main() { let y = sb.mkb() println(x == sa.mka()) println(y == sb.mkb()) - println(x.hash() == sa.mka().hash()) + println(Hash.hash(x) == Hash.hash(sa.mka())) } diff --git a/tests/golden/lang/modules/round94_module_shadowing__derives_survive_module_named_other/main.silt b/tests/golden/lang/modules/round94_module_shadowing__derives_survive_module_named_other/main.silt index ed82a96fd..f296958de 100644 --- a/tests/golden/lang/modules/round94_module_shadowing__derives_survive_module_named_other/main.silt +++ b/tests/golden/lang/modules/round94_module_shadowing__derives_survive_module_named_other/main.silt @@ -7,6 +7,6 @@ fn main() { println(a == P { year: 5 }) println(a < b) println(b < a) - println(a.compare(b)) - println(a.hash() == P { year: 5 }.hash()) + println(Compare.compare(a, b)) + println(Hash.hash(a) == Hash.hash(P { year: 5 })) } diff --git a/tests/golden/lang/modules/span_runtime_error_in_module_trait_method/main.silt b/tests/golden/lang/modules/span_runtime_error_in_module_trait_method/main.silt index 3bd9b88e9..e04f12c9d 100644 --- a/tests/golden/lang/modules/span_runtime_error_in_module_trait_method/main.silt +++ b/tests/golden/lang/modules/span_runtime_error_in_module_trait_method/main.silt @@ -1,8 +1,8 @@ -- exit: 1 -- A runtime error in a trait method a module defines is shown in the -- module, at the method body, not at a line of main.silt. -import util.{ Box } +import util.{ Box, Doer } fn main() { let b = Box { v: 2 } - println(b.act()) + println(Doer.act(b)) } diff --git a/tests/golden/lang/modules/span_type_error_in_imported_module_declaration/a.silt b/tests/golden/lang/modules/span_type_error_in_imported_module_declaration/a.silt index 03c921c39..424555b98 100644 --- a/tests/golden/lang/modules/span_type_error_in_imported_module_declaration/a.silt +++ b/tests/golden/lang/modules/span_type_error_in_imported_module_declaration/a.silt @@ -1,4 +1,4 @@ pub trait Speak { fn speak(self) -> String } pub type Dog { name: String } trait Speak for Dog { fn speak(self) -> String { "woof" } } -pub fn talk(x: t) -> String where t: Speak { x.speak() } +pub fn talk(x: t) -> String where t: Speak { Speak.speak(x) } diff --git a/tests/golden/lang/modules/span_type_error_in_imported_module_declaration/b.silt b/tests/golden/lang/modules/span_type_error_in_imported_module_declaration/b.silt index c0898e0b6..018871892 100644 --- a/tests/golden/lang/modules/span_type_error_in_imported_module_declaration/b.silt +++ b/tests/golden/lang/modules/span_type_error_in_imported_module_declaration/b.silt @@ -1,4 +1,4 @@ pub trait Speak { fn speak(self, times: Int) -> Int } pub type Cat { name: String } trait Speak for Cat { fn speak(self, times: Int) -> Int { times } } -pub fn talk(x: t) -> Int where t: Speak { x.speak(2) } +pub fn talk(x: t) -> Int where t: Speak { Speak.speak(x, 2) } diff --git a/tests/golden/lang/modules/span_type_error_in_imported_module_impl/main.silt b/tests/golden/lang/modules/span_type_error_in_imported_module_impl/main.silt index 2acf10123..8476b4ae2 100644 --- a/tests/golden/lang/modules/span_type_error_in_imported_module_impl/main.silt +++ b/tests/golden/lang/modules/span_type_error_in_imported_module_impl/main.silt @@ -6,5 +6,5 @@ import b fn main() { let c = b.Cat { name: "c" } - println(c.speak()) + println(b.Speak.speak(c)) } diff --git a/tests/golden/lang/qualified/pub_trait_formats.silt b/tests/golden/lang/qualified/pub_trait_formats.silt index 054545f2b..0b2ccf493 100644 --- a/tests/golden/lang/qualified/pub_trait_formats.silt +++ b/tests/golden/lang/qualified/pub_trait_formats.silt @@ -12,5 +12,5 @@ trait Describe for Int { } fn main() { - println(1.describe()) + println(Describe.describe(1)) } diff --git a/tests/golden/lang/qualified/trait_refs/main.silt b/tests/golden/lang/qualified/trait_refs/main.silt index e1c4a4ebb..25b615fc8 100644 --- a/tests/golden/lang/qualified/trait_refs/main.silt +++ b/tests/golden/lang/qualified/trait_refs/main.silt @@ -19,23 +19,23 @@ trait Loud: lib.Describe { trait Loud for Local { fn shout(self) -> String { - "{self.describe()}!" + "{lib.Describe.describe(self)}!" } } trait Loud for lib.Pt { fn shout(self) -> String { - "{self.describe()}!!" + "{lib.Describe.describe(self)}!!" } } fn show(a: a) -> String where a: lib.Describe { - a.describe() + lib.Describe.describe(a) } fn main() { println(show(L(1))) println(show(lib.Pt { x: 1, y: 2 })) - println(L(2).shout()) - println(lib.Pt { x: 3, y: 4 }.shout()) + println(Loud.shout(L(2))) + println(Loud.shout(lib.Pt { x: 3, y: 4 })) } diff --git a/tests/golden/lang/records/a_record_holds_its_fields_in_declaration_order.silt b/tests/golden/lang/records/a_record_holds_its_fields_in_declaration_order.silt index 933fe3614..24430ffd0 100644 --- a/tests/golden/lang/records/a_record_holds_its_fields_in_declaration_order.silt +++ b/tests/golden/lang/records/a_record_holds_its_fields_in_declaration_order.silt @@ -115,7 +115,7 @@ fn main() { println(set.length(set.from_list([a, b, c, d]))) let seen = map.set(map.set(#{}, a, "first"), c, "second") println(map.get(seen, b)) - println(a.hash() == c.hash()) + println(Hash.hash(a) == Hash.hash(c)) -- A decoder builds the record its type declares. match json.parse("\{\"label\": \"j\", \"build\": 5, \"major\": 4}", Ver) { diff --git a/tests/golden/lang/records/round73_row_narrowing__annotated_bogus_field_rejected.silt b/tests/golden/lang/records/round73_row_narrowing__annotated_bogus_field_rejected.silt index 4adb1470f..7489d3061 100644 --- a/tests/golden/lang/records/round73_row_narrowing__annotated_bogus_field_rejected.silt +++ b/tests/golden/lang/records/round73_row_narrowing__annotated_bogus_field_rejected.silt @@ -1,6 +1,6 @@ -- cmd: check -- exit: 1 --- stderr-contains: anon record has no field 'zzznosuchfield' +-- stderr-contains: has no field 'zzznosuchfield' fn pluck(r: {a: Int, b: Int}) { r.zzznosuchfield } fn main() { let p = {a: 1, b: 2} diff --git a/tests/golden/lang/resolve/resolve__builtin_trait_method_through_builtin_type.silt b/tests/golden/lang/resolve/resolve__builtin_trait_method_through_builtin_type.silt index f6b2aeffd..dd2f0beda 100644 --- a/tests/golden/lang/resolve/resolve__builtin_trait_method_through_builtin_type.silt +++ b/tests/golden/lang/resolve/resolve__builtin_trait_method_through_builtin_type.silt @@ -2,17 +2,18 @@ -- The builtin traits' methods of a builtin type are reached through the -- type as through a value: `Int.display(1)` is `1.display()`, called or -- as a function value. +import string fn main() { - println(Int.display(1)) - println(Int.compare(1, 2)) - println(Int.equal(1, 1)) - println(Int.hash(1) == 1.hash()) - println(Float.compare(1.5, 0.5)) - println(String.equal("a", "b")) - println(Bool.display(true)) - println(List.display([1, 2])) - let show = Int.display + println("{1}") + println(Compare.compare(1, 2)) + println(1 == 1) + println(Hash.hash(1) == Hash.hash(1)) + println(Compare.compare(1.5, 0.5)) + println("a" == "b") + println("{true}") + println("{[1, 2]}") + let show = string.from println(show(4)) - let cmp = String.compare + let cmp = Compare.compare println(cmp("a", "b")) } diff --git a/tests/golden/lang/resolve/resolve__builtin_type_without_the_method.silt b/tests/golden/lang/resolve/resolve__builtin_type_without_the_method.silt index 23b5110f3..4563aff90 100644 --- a/tests/golden/lang/resolve/resolve__builtin_type_without_the_method.silt +++ b/tests/golden/lang/resolve/resolve__builtin_type_without_the_method.silt @@ -14,5 +14,5 @@ fn main() { println(Result.compare(Ok(1), Ok(2))) println(Map.compare(1, 2)) println(time.Weekday.nope(1)) - println(Option.display(Some(1))) + println("{Some(1)}") } diff --git a/tests/golden/lang/resolve/resolve__clash_named_in_trait_messages/a.silt b/tests/golden/lang/resolve/resolve__clash_named_in_trait_messages/a.silt index aaa929ea2..5fb69972d 100644 --- a/tests/golden/lang/resolve/resolve__clash_named_in_trait_messages/a.silt +++ b/tests/golden/lang/resolve/resolve__clash_named_in_trait_messages/a.silt @@ -1,3 +1,3 @@ pub trait Show { fn show(self) -> String } trait Show for Int { fn show(self) -> String { "a-int {self}" } } -pub fn use_show(x: t) -> String where t: Show { x.show() } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/resolve/resolve__clash_named_in_trait_messages/b.silt b/tests/golden/lang/resolve/resolve__clash_named_in_trait_messages/b.silt index 2a6dc568c..1cadfcebd 100644 --- a/tests/golden/lang/resolve/resolve__clash_named_in_trait_messages/b.silt +++ b/tests/golden/lang/resolve/resolve__clash_named_in_trait_messages/b.silt @@ -1,3 +1,3 @@ pub trait Show { fn show(self) -> String } trait Show for Int { fn show(self) -> String { "b-int {self}" } } -pub fn use_show(x: t) -> String where t: Show { x.show() } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/resolve/resolve__clash_named_type_and_trait/a.silt b/tests/golden/lang/resolve/resolve__clash_named_type_and_trait/a.silt index 239e93065..2c17b837f 100644 --- a/tests/golden/lang/resolve/resolve__clash_named_type_and_trait/a.silt +++ b/tests/golden/lang/resolve/resolve__clash_named_type_and_trait/a.silt @@ -3,4 +3,4 @@ pub trait Conv { type Out pub type Pt { x: Int } trait Conv for Pt { type Out = Int fn conv(self) -> Int { self.x } } -pub fn run(v: t) -> String where t: Conv { "{v.conv()}" } +pub fn run(v: t) -> String where t: Conv { "{Conv.conv(v)}" } diff --git a/tests/golden/lang/resolve/resolve__clash_named_type_and_trait/b.silt b/tests/golden/lang/resolve/resolve__clash_named_type_and_trait/b.silt index eeb4ae346..98632da1c 100644 --- a/tests/golden/lang/resolve/resolve__clash_named_type_and_trait/b.silt +++ b/tests/golden/lang/resolve/resolve__clash_named_type_and_trait/b.silt @@ -3,4 +3,4 @@ pub trait Conv { type Out pub type Pt { s: String } trait Conv for Pt { type Out = String fn cv(self) -> String { self.s } } -pub fn run(v: t) -> String where t: Conv { "{v.cv()}" } +pub fn run(v: t) -> String where t: Conv { "{Conv.cv(v)}" } diff --git a/tests/golden/lang/resolve/resolve__clash_named_unknown_method/main.silt b/tests/golden/lang/resolve/resolve__clash_named_unknown_method/main.silt index a476ffb86..fa58f3da0 100644 --- a/tests/golden/lang/resolve/resolve__clash_named_unknown_method/main.silt +++ b/tests/golden/lang/resolve/resolve__clash_named_unknown_method/main.silt @@ -1,8 +1,8 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: unknown field or method 'area' on type other.Shape --- other.Shape has no area method; shapes.Shape, imported too, has: the --- message names the type by its module. +-- stderr-contains: error[type]: type 'other.Shape' has no field 'area' +-- other.Shape has no field `area`; shapes.Shape, imported too, has an +-- `Area` impl: the message names the type by its module. import other import shapes fn main() { diff --git a/tests/golden/lang/resolve/resolve__error_message_through_builtin_type.silt b/tests/golden/lang/resolve/resolve__error_message_through_builtin_type.silt index 4222df6c0..40e92c148 100644 --- a/tests/golden/lang/resolve/resolve__error_message_through_builtin_type.silt +++ b/tests/golden/lang/resolve/resolve__error_message_through_builtin_type.silt @@ -8,11 +8,11 @@ fn main() { match io.read_file("/nonexistent/silt/r5") { Ok(_) -> println("ok") Err(e) -> { - println(io.IoError.message(e) == e.message()) - println(IoError.message(e) == e.message()) - println(IoError.display(e) == e.display()) - let m = io.IoError.message - println(m(e) == e.message()) + println(Error.message(e) == Error.message(e)) + println(Error.message(e) == Error.message(e)) + println("{e}" == "{e}") + let m = Error.message + println(m(e) == Error.message(e)) } } } diff --git a/tests/golden/lang/resolve/resolve__private_trait_method/main.silt b/tests/golden/lang/resolve/resolve__private_trait_method/main.silt index c7872c13d..051391d34 100644 --- a/tests/golden/lang/resolve/resolve__private_trait_method/main.silt +++ b/tests/golden/lang/resolve/resolve__private_trait_method/main.silt @@ -1,13 +1,13 @@ -- cmd: check -- exit: 1 -- verdict: same --- stderr-contains: error[type]: method `describe` belongs to trait 'Describe', which is private to module 'shapes' +-- stderr-contains: error[type]: 'Describe' is private to module 'shapes' -- stderr-contains: --> main.silt:12:11 -- The methods of a trait declared without `pub` can be called only in --- its module: `shapes.described` may call `describe`, an importer may --- not, though the type is exported. +-- its module: `shapes.described` may call `Describe.describe`, an +-- importer cannot name the trait, though the type is exported. import shapes fn main() { println(shapes.described(shapes.square(2))) - println(shapes.square(3).describe()) + println(shapes.Describe.describe(shapes.square(3))) } diff --git a/tests/golden/lang/resolve/resolve__private_trait_method/shapes.silt b/tests/golden/lang/resolve/resolve__private_trait_method/shapes.silt index 93517d2f5..76cf0340f 100644 --- a/tests/golden/lang/resolve/resolve__private_trait_method/shapes.silt +++ b/tests/golden/lang/resolve/resolve__private_trait_method/shapes.silt @@ -10,4 +10,4 @@ trait Describe for Square { pub fn square(side: Int) -> Square { Square { side: side } } -pub fn described(s: Square) -> String { s.describe() } +pub fn described(s: Square) -> String { Describe.describe(s) } diff --git a/tests/golden/lang/resolve/resolve__private_trait_method_every_path/lib.silt b/tests/golden/lang/resolve/resolve__private_trait_method_every_path/lib.silt index efee8e3be..f2cd21be9 100644 --- a/tests/golden/lang/resolve/resolve__private_trait_method_every_path/lib.silt +++ b/tests/golden/lang/resolve/resolve__private_trait_method_every_path/lib.silt @@ -4,4 +4,4 @@ trait Priv { trait Priv for Int { fn pm(self) -> Int { self * 10 } } -pub fn via(x: Int) -> Int { x.pm() } +pub fn via(x: Int) -> Int { Priv.pm(x) } diff --git a/tests/golden/lang/resolve/resolve__private_trait_method_every_path/main.silt b/tests/golden/lang/resolve/resolve__private_trait_method_every_path/main.silt index a111a050b..16140c632 100644 --- a/tests/golden/lang/resolve/resolve__private_trait_method_every_path/main.silt +++ b/tests/golden/lang/resolve/resolve__private_trait_method_every_path/main.silt @@ -1,16 +1,16 @@ -- cmd: check -- exit: 1 -- verdict: same --- stderr-contains: --> main.silt:13:18 +-- stderr-contains: --> main.silt:14:11 -- stderr-contains: --> main.silt:15:11 +-- stderr-contains: error[type]: 'Priv' is private to module 'lib' -- stderr-contains: error[type]: method `pm` belongs to trait 'Priv', which is private to module 'lib' -- A private trait's method cannot be called from an importer by any --- path: on a value, through a lambda whose parameter's type is not yet --- known, or through the type. `lib.via` may call it. +-- path: through the trait, which it cannot name, or through the type. +-- `lib.via` may call it. import lib fn main() { println(lib.via(1)) - let f = { x -> x.pm() } - println(f(3)) + println(lib.Priv.pm(3)) println(Int.pm(3)) } diff --git a/tests/golden/lang/resolve/resolve__private_trait_not_nameable/lib.silt b/tests/golden/lang/resolve/resolve__private_trait_not_nameable/lib.silt index ded42c153..8600ce4c5 100644 --- a/tests/golden/lang/resolve/resolve__private_trait_not_nameable/lib.silt +++ b/tests/golden/lang/resolve/resolve__private_trait_not_nameable/lib.silt @@ -1,3 +1,3 @@ trait Hidden { fn hid(self) -> Int } trait Hidden for Int { fn hid(self) -> Int { 7 } } -pub fn seven() -> Int { 7.hid() } +pub fn seven() -> Int { Hidden.hid(7) } diff --git a/tests/golden/lang/resolve/resolve__private_type_in_public_signature/lib.silt b/tests/golden/lang/resolve/resolve__private_type_in_public_signature/lib.silt index 4f2ab6598..b7a29b758 100644 --- a/tests/golden/lang/resolve/resolve__private_type_in_public_signature/lib.silt +++ b/tests/golden/lang/resolve/resolve__private_type_in_public_signature/lib.silt @@ -1,6 +1,6 @@ type Id { Id(Int) } trait Greet { fn greet(self) -> String } pub fn make(n: Int) -> Id { Id(n) } -pub fn hello(x: a) -> String where a: Greet { x.greet() } +pub fn hello(x: a) -> String where a: Greet { Greet.greet(x) } pub type Holder { id: Id } fn private_use(i: Id) -> Int { 1 } diff --git a/tests/golden/lang/resolve/resolve__pub_trait_method/main.silt b/tests/golden/lang/resolve/resolve__pub_trait_method/main.silt index 264587e7f..2bcab2199 100644 --- a/tests/golden/lang/resolve/resolve__pub_trait_method/main.silt +++ b/tests/golden/lang/resolve/resolve__pub_trait_method/main.silt @@ -3,5 +3,5 @@ import shapes fn main() { println(shapes.described(shapes.square(2))) - println(shapes.square(3).describe()) + println(shapes.Describe.describe(shapes.square(3))) } diff --git a/tests/golden/lang/resolve/resolve__pub_trait_method/shapes.silt b/tests/golden/lang/resolve/resolve__pub_trait_method/shapes.silt index 98381e6bd..7cb615f6d 100644 --- a/tests/golden/lang/resolve/resolve__pub_trait_method/shapes.silt +++ b/tests/golden/lang/resolve/resolve__pub_trait_method/shapes.silt @@ -10,4 +10,4 @@ trait Describe for Square { pub fn square(side: Int) -> Square { Square { side: side } } -pub fn described(s: Square) -> String { s.describe() } +pub fn described(s: Square) -> String { Describe.describe(s) } diff --git a/tests/golden/lang/resolve/resolve__qualified_type_method/main.silt b/tests/golden/lang/resolve/resolve__qualified_type_method/main.silt index 0ea75b5b7..61d0698b5 100644 --- a/tests/golden/lang/resolve/resolve__qualified_type_method/main.silt +++ b/tests/golden/lang/resolve/resolve__qualified_type_method/main.silt @@ -13,13 +13,13 @@ trait IntoAppError for io.IoError { } fn load(path: String) -> Result(String, AppError) { - let raw = result.map_err(io.read_file(path), io.IoError.into_app_error)? + let raw = result.map_err(io.read_file(path), IntoAppError.into_app_error)? Ok(raw) } fn main() { - println(lib.Shape.describe(lib.Shape.Circle(1))) - println(lib.Pt.describe(lib.Pt { x: 2 })) + println(lib.Describe.describe(lib.Shape.Circle(1))) + println(lib.Describe.describe(lib.Pt { x: 2 })) match load("/nonexistent/silt/golden") { Ok(_) -> println("ok") Err(AppError.IoProblem(_)) -> println("io problem") diff --git a/tests/golden/lang/resolve/resolve__rejected_impl_method_not_reported_again/lib.silt b/tests/golden/lang/resolve/resolve__rejected_impl_method_not_reported_again/lib.silt index ded42c153..8600ce4c5 100644 --- a/tests/golden/lang/resolve/resolve__rejected_impl_method_not_reported_again/lib.silt +++ b/tests/golden/lang/resolve/resolve__rejected_impl_method_not_reported_again/lib.silt @@ -1,3 +1,3 @@ trait Hidden { fn hid(self) -> Int } trait Hidden for Int { fn hid(self) -> Int { 7 } } -pub fn seven() -> Int { 7.hid() } +pub fn seven() -> Int { Hidden.hid(7) } diff --git a/tests/golden/lang/resolve/resolve__rejected_impl_method_not_reported_again/main.silt b/tests/golden/lang/resolve/resolve__rejected_impl_method_not_reported_again/main.silt index db496a14d..fc0f0f554 100644 --- a/tests/golden/lang/resolve/resolve__rejected_impl_method_not_reported_again/main.silt +++ b/tests/golden/lang/resolve/resolve__rejected_impl_method_not_reported_again/main.silt @@ -6,5 +6,5 @@ import lib trait Hidden for String { fn hid(self) -> Int { 1 } } fn main() { - println("a".hid()) + println(Hidden.hid("a")) } diff --git a/tests/golden/lang/resolve/resolve__s4_module_trait_beside_local_trait/main.silt b/tests/golden/lang/resolve/resolve__s4_module_trait_beside_local_trait/main.silt index e0cbeb82d..28ebc275f 100644 --- a/tests/golden/lang/resolve/resolve__s4_module_trait_beside_local_trait/main.silt +++ b/tests/golden/lang/resolve/resolve__s4_module_trait_beside_local_trait/main.silt @@ -8,8 +8,8 @@ type X { X(Int) } type Y { Y(Int) } trait lib.Describe for X { fn describe(self) -> String { "lib" } } trait Describe for Y { fn describe(self) -> Int { 7 } } -fn show(a: a) -> String where a: lib.Describe { a.describe() } -fn count(a: a) -> Int where a: Describe { a.describe() } +fn show(a: a) -> String where a: lib.Describe { lib.Describe.describe(a) } +fn count(a: a) -> Int where a: Describe { Describe.describe(a) } fn main() { println(show(X(1))) println(count(Y(2)) + 1) diff --git a/tests/golden/lang/resolve/resolve__s4_module_trait_is_not_local_trait/main.silt b/tests/golden/lang/resolve/resolve__s4_module_trait_is_not_local_trait/main.silt index 54100f956..73ab1ff88 100644 --- a/tests/golden/lang/resolve/resolve__s4_module_trait_is_not_local_trait/main.silt +++ b/tests/golden/lang/resolve/resolve__s4_module_trait_is_not_local_trait/main.silt @@ -8,7 +8,7 @@ import lib trait Describe { fn describe(self) -> Int } type X { X(Int) } trait lib.Describe for X { fn describe(self) -> String { "lib" } } -fn count(a: a) -> Int where a: Describe { a.describe() } +fn count(a: a) -> Int where a: Describe { Describe.describe(a) } fn main() { println(count(X(1))) } diff --git a/tests/golden/lang/resolve/resolve__two_modules_one_type_name_with_impls/main.silt b/tests/golden/lang/resolve/resolve__two_modules_one_type_name_with_impls/main.silt index 38989d5a1..17fc4a2a1 100644 --- a/tests/golden/lang/resolve/resolve__two_modules_one_type_name_with_impls/main.silt +++ b/tests/golden/lang/resolve/resolve__two_modules_one_type_name_with_impls/main.silt @@ -7,12 +7,12 @@ import a import b fn both(p: a.Pt, q: b.Pt) -> String { - "{p.display()} / {q.display()} / {p.x} {q.y}" + "{p} / {q} / {p.x} {q.y}" } fn main() { - println(a.mk().display()) - println(b.mk().display()) - println(a.Pt.display(a.mk())) + println("{a.mk()}") + println("{b.mk()}") + println("{a.mk()}") println(both(a.mk(), b.mk())) println(a.mk()) println(b.mk()) diff --git a/tests/golden/lang/resolve/resolve__type_method_that_is_a_module_function.silt b/tests/golden/lang/resolve/resolve__type_method_that_is_a_module_function.silt index df38ef449..4871803e9 100644 --- a/tests/golden/lang/resolve/resolve__type_method_that_is_a_module_function.silt +++ b/tests/golden/lang/resolve/resolve__type_method_that_is_a_module_function.silt @@ -9,5 +9,5 @@ -- program is checked, not when it runs. fn main() { println(Int.parse("3")) - println(Int.display(3)) + println("{3}") } diff --git a/tests/golden/lang/session/stage5_session__poisoned_module_named_like_a_local_type/case.stderr b/tests/golden/lang/session/stage5_session__poisoned_module_named_like_a_local_type/case.stderr index c2a6c3e50..b61040876 100644 --- a/tests/golden/lang/session/stage5_session__poisoned_module_named_like_a_local_type/case.stderr +++ b/tests/golden/lang/session/stage5_session__poisoned_module_named_like_a_local_type/case.stderr @@ -35,8 +35,9 @@ error[parse]: expected declaration, found = 6 | import Shape | ------------ module 'Shape' is imported here -error[type]: unknown field or method 'describe' on type Shape +error[type]: type 'Shape' has no field 'describe' --> main.silt:20:11 | 20 | println(s.describe()) - | ^^^^^^^^^^ unknown field or method 'describe' on type Shape + | ^^^^^^^^^^ type 'Shape' has no field 'describe' + = help: `describe` is a method of trait `Describe`: call it as `Describe.describe(s)` diff --git a/tests/golden/lang/session/stage5_session__type_alias_per_module_ab/a.silt b/tests/golden/lang/session/stage5_session__type_alias_per_module_ab/a.silt index 0dd499815..cde98c207 100644 --- a/tests/golden/lang/session/stage5_session__type_alias_per_module_ab/a.silt +++ b/tests/golden/lang/session/stage5_session__type_alias_per_module_ab/a.silt @@ -1,4 +1,4 @@ type Id = Int trait Show2 { fn show2(self) -> String } trait Show2 for Id { fn show2(self) -> String { "int-id" } } -pub fn f(x: Int) -> String { x.show2() } +pub fn f(x: Int) -> String { Show2.show2(x) } diff --git a/tests/golden/lang/session/stage5_session__type_alias_per_module_ba/a.silt b/tests/golden/lang/session/stage5_session__type_alias_per_module_ba/a.silt index 0dd499815..cde98c207 100644 --- a/tests/golden/lang/session/stage5_session__type_alias_per_module_ba/a.silt +++ b/tests/golden/lang/session/stage5_session__type_alias_per_module_ba/a.silt @@ -1,4 +1,4 @@ type Id = Int trait Show2 { fn show2(self) -> String } trait Show2 for Id { fn show2(self) -> String { "int-id" } } -pub fn f(x: Int) -> String { x.show2() } +pub fn f(x: Int) -> String { Show2.show2(x) } diff --git a/tests/golden/lang/soundness/alias_impl__another_length_or_arity_has_no_impl.silt b/tests/golden/lang/soundness/alias_impl__another_length_or_arity_has_no_impl.silt index 3c45e636f..75379832a 100644 --- a/tests/golden/lang/soundness/alias_impl__another_length_or_arity_has_no_impl.silt +++ b/tests/golden/lang/soundness/alias_impl__another_length_or_arity_has_no_impl.silt @@ -18,8 +18,8 @@ trait T for P2 { } trait U { fn ap(self) -> Int } trait U for Op { fn ap(self) -> Int { self(1) + 1 } } -fn s(x: a) -> Int where a: T { x.sum() } -fn u(x: a) -> Int where a: U { x.ap() } +fn s(x: a) -> Int where a: T { T.sum(x) } +fn u(x: a) -> Int where a: U { U.ap(x) } fn two(a: Int, b: Int) -> Int { a + b } fn tag(n: Int) -> Tag { Tag("t") } fn main() { diff --git a/tests/golden/lang/soundness/c2.silt b/tests/golden/lang/soundness/c2.silt index 05768a29d..d098be07d 100644 --- a/tests/golden/lang/soundness/c2.silt +++ b/tests/golden/lang/soundness/c2.silt @@ -2,7 +2,7 @@ -- exit: 1 -- stderr-contains: error[type]: type 'Fn' does not implement trait 'Display' -- Port of repros/type_soundness/c2.silt, in brace closures. -fn show(x) { x.display() } +fn show(x) { "{x}" } fn main() { let f = { x -> x + 1 } println(show(1)) diff --git a/tests/golden/lang/soundness/d06.silt b/tests/golden/lang/soundness/d06.silt index 8c5b630da..b079ea17d 100644 --- a/tests/golden/lang/soundness/d06.silt +++ b/tests/golden/lang/soundness/d06.silt @@ -12,7 +12,7 @@ trait S { trait S for F {} fn main() { let x = F { f: { a -> a } } - println(x.s()) - println(x.e()) - println(x.c()) + println(S.s(x)) + println(S.e(x)) + println(S.c(x)) } diff --git a/tests/golden/lang/soundness/d5.silt b/tests/golden/lang/soundness/d5.silt index 17941d7aa..109f46a30 100644 --- a/tests/golden/lang/soundness/d5.silt +++ b/tests/golden/lang/soundness/d5.silt @@ -1,8 +1,8 @@ -- cmd: check -- exit: 1 --- stderr-contains: unknown method 'display' on type Fn +-- stderr-contains: has no field 'display' -- Port of repros/type_soundness/d5.silt, in brace closures. -fn f(x) { x.display() } +fn f(x) { "{x}" } fn main() { let g = { x -> x } println(g.display()) diff --git a/tests/golden/lang/soundness/e05.silt b/tests/golden/lang/soundness/e05.silt index 08903f18b..12b6b7f31 100644 --- a/tests/golden/lang/soundness/e05.silt +++ b/tests/golden/lang/soundness/e05.silt @@ -6,6 +6,6 @@ trait Loud { fn loud(self) -> String } trait Loud for Int { fn loud(self) -> String { "INT" } } trait Shw { fn shw(self, x: a) -> String } -trait Shw for Bool { fn shw(self, x: a) -> String where a: Loud { x.loud() } } -fn call(s: t, v: String) -> String where t: Shw { s.shw(v) } +trait Shw for Bool { fn shw(self, x: a) -> String where a: Loud { Loud.loud(x) } } +fn call(s: t, v: String) -> String where t: Shw { Shw.shw(s, v) } fn main() { println(call(true, "s")) } diff --git a/tests/golden/lang/soundness/e12.silt b/tests/golden/lang/soundness/e12.silt index f6524c021..840b5a86b 100644 --- a/tests/golden/lang/soundness/e12.silt +++ b/tests/golden/lang/soundness/e12.silt @@ -5,7 +5,7 @@ trait Greet { fn greet(self) -> String } trait Greet for P { fn greet(self) -> String { "p" } } fn main() { let ps = [P { v: 1 }] - let f = { p -> p.greet() } + let f = { p -> Greet.greet(p) } println(f(P { v: 2 })) println(list.map(ps, f)) } diff --git a/tests/golden/lang/soundness/e4.silt b/tests/golden/lang/soundness/e4.silt index 5197e3763..e6e0589fc 100644 --- a/tests/golden/lang/soundness/e4.silt +++ b/tests/golden/lang/soundness/e4.silt @@ -1,11 +1,11 @@ -- cmd: check -- exit: 1 --- stderr-contains: type mismatch: expected {nonexistent_method: Fn() -> _, ...}, got Int +-- stderr-contains: type 'Int' has no field 'nonexistent_method' -- Port of repros/type_soundness/e4.silt, in brace closures. import list fn main() { let xs = [1, 2, 3] - let ys = list.map(xs) { x -> x.display() } + let ys = list.map(xs) { x -> "{x}" } println(ys) let f = { x -> x.nonexistent_method() } println(f(1)) diff --git a/tests/golden/lang/soundness/e5.silt b/tests/golden/lang/soundness/e5.silt index d38e102f2..b8caa24a3 100644 --- a/tests/golden/lang/soundness/e5.silt +++ b/tests/golden/lang/soundness/e5.silt @@ -3,7 +3,7 @@ -- stderr-contains: error[type]: type mismatch: expected Int, got String -- Port of repros/type_soundness/e5.silt, in brace closures. fn main() { - let f = { x -> x.display() } + let f = { x -> "{x}" } let n: Int = f(1) println(n) } diff --git a/tests/golden/lang/soundness/e7.silt b/tests/golden/lang/soundness/e7.silt index de7878271..4a861c255 100644 --- a/tests/golden/lang/soundness/e7.silt +++ b/tests/golden/lang/soundness/e7.silt @@ -2,7 +2,7 @@ import list fn main() { let xs = [1, 2, 3] - let ys = list.map(xs, { x: Int -> x.display() }) + let ys = list.map(xs, { x: Int -> "{x}" }) println(ys) - println(1.display()) + println("{1}") } diff --git a/tests/golden/lang/soundness/every_fn__a_closure_returned_as_a_function_of_a_variant.silt b/tests/golden/lang/soundness/every_fn__a_closure_returned_as_a_function_of_a_variant.silt index 812f0055d..5e687ad1d 100644 --- a/tests/golden/lang/soundness/every_fn__a_closure_returned_as_a_function_of_a_variant.silt +++ b/tests/golden/lang/soundness/every_fn__a_closure_returned_as_a_function_of_a_variant.silt @@ -8,7 +8,7 @@ trait Cast for Fn { fn cast(self) -> Fn(Int) -> Solo { self } } fn main() { - let f = { n -> n * 2 }.cast() + let f = Cast.cast({ n -> n * 2 }) match f(21) { Solo(s) -> println("got {s}") } diff --git a/tests/golden/lang/soundness/every_fn__not_called_through_the_type.silt b/tests/golden/lang/soundness/every_fn__not_called_through_the_type.silt index 9dacc0abc..6f1cd4e31 100644 --- a/tests/golden/lang/soundness/every_fn__not_called_through_the_type.silt +++ b/tests/golden/lang/soundness/every_fn__not_called_through_the_type.silt @@ -1,9 +1,10 @@ -- cmd: check -- exit: 1 --- stderr-contains: method `describe` of the impl for every `Fn` is called on a value: write `x.describe(..)`, not `Fn.describe` --- stderr-contains: method `describe` of the impl for every `Tuple` is called on a value: write `x.describe(..)`, not `Tuple.describe` --- The impl for every function is found by the receiver. Written through --- the type its method would take a `self` of any type: refused. +-- stderr-contains: type 'Fn' has no method 'describe' +-- stderr-contains: type 'Tuple' has no method 'describe' +-- stderr-contains: help: `describe` is a method of trait `D`: call it as `D.describe(x)` +-- The impl for every function is found by the argument of type Self: +-- the method is called through its trait, never through the type. trait D { fn describe(self) -> String } trait D for Fn { fn describe(self) -> String { "fn" } } trait D for Tuple { fn describe(self) -> String { "tuple" } } diff --git a/tests/golden/lang/soundness/every_fn__self_is_not_a_function_of_a_chosen_signature.silt b/tests/golden/lang/soundness/every_fn__self_is_not_a_function_of_a_chosen_signature.silt index 1aba36076..9a5e4a4ef 100644 --- a/tests/golden/lang/soundness/every_fn__self_is_not_a_function_of_a_chosen_signature.silt +++ b/tests/golden/lang/soundness/every_fn__self_is_not_a_function_of_a_chosen_signature.silt @@ -17,10 +17,10 @@ fn show(c: Cents) -> String { } } fn main() { - let f = secret.cast() + let f = Cast.cast(secret) println(show(f(1))) let Cents(k) = f(2) println("bound: {k}") - let g = open.cast() + let g = Cast.cast(open) println(show(g(1))) } diff --git a/tests/golden/lang/soundness/every_fn__self_returned_as_a_function_of_a_record.silt b/tests/golden/lang/soundness/every_fn__self_returned_as_a_function_of_a_record.silt index cd843fba3..a6ef76a58 100644 --- a/tests/golden/lang/soundness/every_fn__self_returned_as_a_function_of_a_record.silt +++ b/tests/golden/lang/soundness/every_fn__self_returned_as_a_function_of_a_record.silt @@ -10,7 +10,7 @@ trait Cast for Fn { } fn mk(n: Int) -> Point { Point { x: "px", y: "py" } } fn main() { - let f = mk.cast() + let f = Cast.cast(mk) let Wrap(n) = f(1) println(n + 1) } diff --git a/tests/golden/lang/soundness/every_tuple__self_is_not_a_tuple_of_chosen_elements.silt b/tests/golden/lang/soundness/every_tuple__self_is_not_a_tuple_of_chosen_elements.silt index 9f635dd8e..a2f8c4e45 100644 --- a/tests/golden/lang/soundness/every_tuple__self_is_not_a_tuple_of_chosen_elements.silt +++ b/tests/golden/lang/soundness/every_tuple__self_is_not_a_tuple_of_chosen_elements.silt @@ -15,7 +15,7 @@ fn len(m: Meters) -> String { } } fn main() { - let (m, _) = (Feet { v: 3, unit: "ft" }, 0).cast() + let (m, _) = Cast.cast((Feet { v: 3, unit: "ft" }, 0)) println(len(m)) let Meters { v, .. } = m println(v) diff --git a/tests/golden/lang/soundness/every_tuple__self_returned_as_a_tuple_of_a_record.silt b/tests/golden/lang/soundness/every_tuple__self_returned_as_a_tuple_of_a_record.silt index a7e4c3f0e..4a697cb87 100644 --- a/tests/golden/lang/soundness/every_tuple__self_returned_as_a_tuple_of_a_record.silt +++ b/tests/golden/lang/soundness/every_tuple__self_returned_as_a_tuple_of_a_record.silt @@ -9,6 +9,6 @@ trait Cast for Tuple { fn cast(self) -> (Point, Int) { self } } fn main() { - let (Point { x, y }, k) = (Wrap(7), 2).cast() + let (Point { x, y }, k) = Cast.cast((Wrap(7), 2)) println("{x} {y} {k}") } diff --git a/tests/golden/lang/soundness/every_tuple__self_returned_as_a_tuple_of_a_variant.silt b/tests/golden/lang/soundness/every_tuple__self_returned_as_a_tuple_of_a_variant.silt index 2a3670441..529928cef 100644 --- a/tests/golden/lang/soundness/every_tuple__self_returned_as_a_tuple_of_a_variant.silt +++ b/tests/golden/lang/soundness/every_tuple__self_returned_as_a_tuple_of_a_variant.silt @@ -9,6 +9,6 @@ trait Cast for Tuple { fn cast(self) -> (Wrap, Int) { self } } fn main() { - let (Wrap(n), k) = (Point { x: "px", y: "py" }, 2).cast() + let (Wrap(n), k) = Cast.cast((Point { x: "px", y: "py" }, 2)) println(n + k) } diff --git a/tests/golden/lang/soundness/every_tuple__self_type_is_the_receivers.silt b/tests/golden/lang/soundness/every_tuple__self_type_is_the_receivers.silt index 3a9d1b4d8..653f76bcf 100644 --- a/tests/golden/lang/soundness/every_tuple__self_type_is_the_receivers.silt +++ b/tests/golden/lang/soundness/every_tuple__self_type_is_the_receivers.silt @@ -9,6 +9,6 @@ trait Same for Tuple { fn other(self, o: Self) -> Self { o } } fn main() { - let (Cents(k), _) = (Cents(1), 2).other((Hidden("s3cr3t"), 2, 3)) + let (Cents(k), _) = Same.other((Cents(1), 2), (Hidden("s3cr3t"), 2, 3)) println("bound: {k}") } diff --git a/tests/golden/lang/soundness/i5.silt b/tests/golden/lang/soundness/i5.silt index 73837f8be..c5a2a8747 100644 --- a/tests/golden/lang/soundness/i5.silt +++ b/tests/golden/lang/soundness/i5.silt @@ -5,7 +5,7 @@ type W(a) { W(a) } fn main() { let w1 = W({ x -> x + 1 }) - println(w1.display()) + println("{w1}") println("{w1}") println(w1) } diff --git a/tests/golden/lang/soundness/i8.silt b/tests/golden/lang/soundness/i8.silt index fad819ede..e75e002b2 100644 --- a/tests/golden/lang/soundness/i8.silt +++ b/tests/golden/lang/soundness/i8.silt @@ -8,7 +8,7 @@ fn main() { let u = Node(Node(Leaf, 1, Leaf), 2, Leaf) println(t == u) println(t < u) - println(t.hash() == u.hash()) + println(Hash.hash(t) == Hash.hash(u)) println(t) let ft = Node(Leaf, { x -> x }, Leaf) println(ft == ft) diff --git a/tests/golden/lang/soundness/se2.silt b/tests/golden/lang/soundness/se2.silt index 049982381..6a9efe92e 100644 --- a/tests/golden/lang/soundness/se2.silt +++ b/tests/golden/lang/soundness/se2.silt @@ -11,7 +11,7 @@ trait Get for P { } } fn main() { - println(P { v: 1 }.get()) + println(Get.get(P { v: 1 })) let g = { x -> self } println(1) } diff --git a/tests/golden/lang/soundness/t_poly_method.silt b/tests/golden/lang/soundness/t_poly_method.silt index ae5e4d9c2..22beaed84 100644 --- a/tests/golden/lang/soundness/t_poly_method.silt +++ b/tests/golden/lang/soundness/t_poly_method.silt @@ -2,7 +2,7 @@ -- exit: 1 -- stderr-contains: error[type]: type 'Fn' does not implement trait 'Display' -- Port of repros/typechecker_arch/t_poly_method.silt, in brace closures. -fn show(x) { x.display() } +fn show(x) { "{x}" } fn main() { let f = { y -> y } println(show(f) + 1) diff --git a/tests/golden/lang/soundness/w10.silt b/tests/golden/lang/soundness/w10.silt index e09d3498b..017774270 100644 --- a/tests/golden/lang/soundness/w10.silt +++ b/tests/golden/lang/soundness/w10.silt @@ -5,7 +5,7 @@ import list trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { println(list.map(["a", "b"], { x -> hello(x) })) } diff --git a/tests/golden/lang/soundness/w5.silt b/tests/golden/lang/soundness/w5.silt index 133a59364..8be05bc1c 100644 --- a/tests/golden/lang/soundness/w5.silt +++ b/tests/golden/lang/soundness/w5.silt @@ -4,7 +4,7 @@ -- Port of repros/type_soundness/w5.silt, in brace closures. trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { let h = hello println(h("s")) diff --git a/tests/golden/lang/soundness/z1.silt b/tests/golden/lang/soundness/z1.silt index 60095dd3d..ae8596038 100644 --- a/tests/golden/lang/soundness/z1.silt +++ b/tests/golden/lang/soundness/z1.silt @@ -5,7 +5,7 @@ import channel type Box(a) { Box(a) } fn show(x) { "{x}" } -fn show2(x) { x.display() } +fn show2(x) { "{x}" } fn pr(x) { println(x) } fn main() { let f = { x -> x } diff --git a/tests/golden/lang/soundness/z2.silt b/tests/golden/lang/soundness/z2.silt index f940360cd..52ce2a389 100644 --- a/tests/golden/lang/soundness/z2.silt +++ b/tests/golden/lang/soundness/z2.silt @@ -4,7 +4,7 @@ -- Port of repros/type_soundness/z2.silt, in brace closures. type Box(a) { Box(a) } fn show(x) { "{x}" } -fn show2(x) { x.display() } +fn show2(x) { "{x}" } fn pr(x) { println(x) } fn main() { let f = { x -> x } diff --git a/tests/golden/lang/soundness/z3.silt b/tests/golden/lang/soundness/z3.silt index 77a08ba29..4cb010c9d 100644 --- a/tests/golden/lang/soundness/z3.silt +++ b/tests/golden/lang/soundness/z3.silt @@ -4,7 +4,7 @@ -- Port of repros/type_soundness/z3.silt, in brace closures. type Box(a) { Box(a) } fn show(x) { "{x}" } -fn show2(x) { x.display() } +fn show2(x) { "{x}" } fn pr(x) { println(x) } fn main() { let f = { x -> x } diff --git a/tests/golden/lang/stdlib/bytes_module__base64.silt b/tests/golden/lang/stdlib/bytes_module__base64.silt index 35d8817a7..a3e031c78 100644 --- a/tests/golden/lang/stdlib/bytes_module__base64.silt +++ b/tests/golden/lang/stdlib/bytes_module__base64.silt @@ -9,6 +9,6 @@ fn main() { println(bytes.to_base64(bytes.from_string("hello"))) match bytes.from_base64("!!!not base64!!!") { Ok(_) -> println("wrong: should error") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/stdlib/bytes_module__concat.silt b/tests/golden/lang/stdlib/bytes_module__concat.silt index b5180fd08..bfc99931d 100644 --- a/tests/golden/lang/stdlib/bytes_module__concat.silt +++ b/tests/golden/lang/stdlib/bytes_module__concat.silt @@ -4,7 +4,7 @@ fn main() { let b = bytes.from_string("world") match bytes.to_string(bytes.concat(a, b)) { Ok(s) -> println(s) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } let h = bytes.from_string("hello") println(bytes.concat(h, bytes.empty()) == h) @@ -16,6 +16,6 @@ fn main() { ] match bytes.to_string(bytes.concat_all(parts)) { Ok(s) -> println(s) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/stdlib/bytes_module__constructors.silt b/tests/golden/lang/stdlib/bytes_module__constructors.silt index 3d718f0c0..969a6131c 100644 --- a/tests/golden/lang/stdlib/bytes_module__constructors.silt +++ b/tests/golden/lang/stdlib/bytes_module__constructors.silt @@ -5,11 +5,11 @@ fn main() { -- from_string / to_string round trip, ascii and multibyte match bytes.to_string(bytes.from_string("hello")) { Ok(s) -> println(s) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match bytes.to_string(bytes.from_string("café 🎉")) { Ok(s) -> println(s) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } -- 0xff alone is not valid utf-8 match bytes.from_list([255]) { diff --git a/tests/golden/lang/stdlib/bytes_module__hex.silt b/tests/golden/lang/stdlib/bytes_module__hex.silt index e3d49825e..76659898c 100644 --- a/tests/golden/lang/stdlib/bytes_module__hex.silt +++ b/tests/golden/lang/stdlib/bytes_module__hex.silt @@ -2,20 +2,20 @@ import bytes fn main() { match bytes.from_hex("48656c6c6f") { Ok(b) -> println(bytes.to_hex(b)) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } -- uppercase input is accepted, output is lowercase match bytes.from_hex("DEADBEEF") { Ok(b) -> println(bytes.to_hex(b)) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match bytes.from_hex("abc") { Ok(_) -> println("wrong: should error") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match bytes.from_hex("xyzz") { Ok(_) -> println("wrong: should error") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println("[{bytes.to_hex(bytes.empty())}]") } diff --git a/tests/golden/lang/stdlib/bytes_module__length_slice_get.silt b/tests/golden/lang/stdlib/bytes_module__length_slice_get.silt index eb207b7b1..a3533aa00 100644 --- a/tests/golden/lang/stdlib/bytes_module__length_slice_get.silt +++ b/tests/golden/lang/stdlib/bytes_module__length_slice_get.silt @@ -5,7 +5,7 @@ fn main() { println([a, b]) match bytes.to_string(bytes.slice(bytes.from_string("hello world"), 6, 11)) { Ok(t) -> println(t) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println(bytes.length(bytes.slice(bytes.from_string("hello"), 2, 2))) -- a start past the end gives nothing; an end past the length is the length diff --git a/tests/golden/lang/stdlib/bytes_module__list_conversion.silt b/tests/golden/lang/stdlib/bytes_module__list_conversion.silt index e5d619e9f..b2f8c387a 100644 --- a/tests/golden/lang/stdlib/bytes_module__list_conversion.silt +++ b/tests/golden/lang/stdlib/bytes_module__list_conversion.silt @@ -6,10 +6,10 @@ fn main() { } match bytes.from_list([10, 256, 30]) { Ok(_) -> println("wrong: should error") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match bytes.from_list([0, -1, 0]) { Ok(_) -> println("wrong: should error") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/stdlib/bytes_module__split.silt b/tests/golden/lang/stdlib/bytes_module__split.silt index 25f98f736..39d37765b 100644 --- a/tests/golden/lang/stdlib/bytes_module__split.silt +++ b/tests/golden/lang/stdlib/bytes_module__split.silt @@ -5,7 +5,7 @@ fn main() { println(list.map(parts) { p -> match bytes.to_string(p) { Ok(s) -> s - Err(e) -> e.message() + Err(e) -> Error.message(e) } }) println(list.length(bytes.split(bytes.from_string("hello"), bytes.from_string(",")))) diff --git a/tests/golden/lang/stdlib/conventions__encoding_crypto_and_uuid_have_typed_errors.silt b/tests/golden/lang/stdlib/conventions__encoding_crypto_and_uuid_have_typed_errors.silt index 969b42e9e..234e9f5b9 100644 --- a/tests/golden/lang/stdlib/conventions__encoding_crypto_and_uuid_have_typed_errors.silt +++ b/tests/golden/lang/stdlib/conventions__encoding_crypto_and_uuid_have_typed_errors.silt @@ -19,7 +19,7 @@ fn main() { other -> println(other) } match encoding.form_decode("%FF=1") { - Err(e) -> println("form_decode: {e.message()}") + Err(e) -> println("form_decode: {Error.message(e)}") Ok(pairs) -> println(pairs) } match crypto.random_bytes(-1) { @@ -27,7 +27,7 @@ fn main() { _ -> println("something else") } match crypto.random_bytes(2000000) { - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) Ok(_) -> println("two million bytes") } match uuid.parse("not-a-uuid") { diff --git a/tests/golden/lang/stdlib/conventions__error_enums_are_named_after_their_modules.silt b/tests/golden/lang/stdlib/conventions__error_enums_are_named_after_their_modules.silt index 512bfda6d..5f4c643f1 100644 --- a/tests/golden/lang/stdlib/conventions__error_enums_are_named_after_their_modules.silt +++ b/tests/golden/lang/stdlib/conventions__error_enums_are_named_after_their_modules.silt @@ -13,7 +13,7 @@ import toml type Point { x: Int } -fn show(e: a) -> String where a: Error { e.message() } +fn show(e: a) -> String where a: Error { Error.message(e) } fn main() { match io.read_file("no/such/file/anywhere") { diff --git a/tests/golden/lang/stdlib/crypto_module__hmac_kats.silt b/tests/golden/lang/stdlib/crypto_module__hmac_kats.silt index d1c92e8e2..7ca9b4eec 100644 --- a/tests/golden/lang/stdlib/crypto_module__hmac_kats.silt +++ b/tests/golden/lang/stdlib/crypto_module__hmac_kats.silt @@ -7,7 +7,7 @@ fn main() { println(bytes.to_hex(crypto.hmac_sha256(key, bytes.from_string("Hi There")))) println(bytes.to_hex(crypto.hmac_sha512(key, bytes.from_string("Hi There")))) } - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println(bytes.length(crypto.hmac_sha256(bytes.from_string("k"), bytes.from_string("m")))) println(bytes.length(crypto.hmac_sha512(bytes.from_string("k"), bytes.from_string("m")))) diff --git a/tests/golden/lang/stdlib/data_decode__a_bounded_type_another_decoder_refuses_is_one_error.silt b/tests/golden/lang/stdlib/data_decode__a_bounded_type_another_decoder_refuses_is_one_error.silt index 5e4e32068..b4c03ecbd 100644 --- a/tests/golden/lang/stdlib/data_decode__a_bounded_type_another_decoder_refuses_is_one_error.silt +++ b/tests/golden/lang/stdlib/data_decode__a_bounded_type_another_decoder_refuses_is_one_error.silt @@ -46,7 +46,7 @@ trait Load for S { } fn via(x: s, type a) -> Result(a, toml.TomlError) where s: Load, a: json.Decode { - x.get("n = 1", a) + Load.get(x, "n = 1", a) } fn main() { @@ -56,6 +56,6 @@ fn main() { let _ = deep("n = 1", L) let _ = both("n = 1", L) let _ = tl("n = 1", Set(Int)) - let _ = S { n: 1 }.get("n = 1", L) + let _ = Load.get(S { n: 1 }, "n = 1", L) let _ = via(S { n: 1 }, L) } diff --git a/tests/golden/lang/stdlib/data_decode__a_bounded_type_another_decoder_refuses_is_one_error.stderr b/tests/golden/lang/stdlib/data_decode__a_bounded_type_another_decoder_refuses_is_one_error.stderr index 7552edac5..7eeed2c80 100644 --- a/tests/golden/lang/stdlib/data_decode__a_bounded_type_another_decoder_refuses_is_one_error.stderr +++ b/tests/golden/lang/stdlib/data_decode__a_bounded_type_another_decoder_refuses_is_one_error.stderr @@ -47,10 +47,10 @@ error[type]: `toml.parse` cannot decode `Set(Int)`: its type argument must be a = help: declare a record type with a field of the type you want, and decode into the record error[type]: `toml.parse` cannot decode `L`: its type argument must be a record type, an enum type, or a type with a `json.Decode` impl - --> data_decode__a_bounded_type_another_decoder_refuses_is_one_error.silt:59:35 + --> data_decode__a_bounded_type_another_decoder_refuses_is_one_error.silt:59:41 | - 59 | let _ = S { n: 1 }.get("n = 1", L) - | ^ `toml.parse` cannot decode `L`: its type argument must be a record type, an enum type, or a type with a `json.Decode` impl + 59 | let _ = Load.get(S { n: 1 }, "n = 1", L) + | ^ `toml.parse` cannot decode `L`: its type argument must be a record type, an enum type, or a type with a `json.Decode` impl = note: `S.get` passes it to `toml.parse` = help: use `toml.parse_list` for a list diff --git a/tests/golden/lang/stdlib/data_decode__a_closure_passes_its_type_to_a_trait_method_on_a_type_variable.silt b/tests/golden/lang/stdlib/data_decode__a_closure_passes_its_type_to_a_trait_method_on_a_type_variable.silt index 901c5d882..168c03781 100644 --- a/tests/golden/lang/stdlib/data_decode__a_closure_passes_its_type_to_a_trait_method_on_a_type_variable.silt +++ b/tests/golden/lang/stdlib/data_decode__a_closure_passes_its_type_to_a_trait_method_on_a_type_variable.silt @@ -14,7 +14,7 @@ trait Loader { fn text(self) -> String fn load(self, type a) -> Result(a, json.JsonError) where a: json.Decode fn load_by_closure(self, type a) -> Result(a, json.JsonError) where a: json.Decode { - let g = { t -> self.load(t) } + let g = { t -> Loader.load(self, t) } g(a) } } @@ -29,7 +29,7 @@ trait Loader for Src { } fn go(l: l, type b) -> Result(b, json.JsonError) where l: Loader, b: json.Decode { - let g = { t -> l.load(t) } + let g = { t -> Loader.load(l, t) } g(b) } @@ -37,5 +37,5 @@ fn main() { let src = Src { s: "\{\"n\": 1}" } let _ = go(src, Fine) let _ = go(src, Blob) - let _ = src.load_by_closure(Blob) + let _ = Loader.load_by_closure(src, Blob) } diff --git a/tests/golden/lang/stdlib/data_decode__a_closure_passes_its_type_to_a_trait_method_on_a_type_variable.stderr b/tests/golden/lang/stdlib/data_decode__a_closure_passes_its_type_to_a_trait_method_on_a_type_variable.stderr index fed686db7..3f9cf90e0 100644 --- a/tests/golden/lang/stdlib/data_decode__a_closure_passes_its_type_to_a_trait_method_on_a_type_variable.stderr +++ b/tests/golden/lang/stdlib/data_decode__a_closure_passes_its_type_to_a_trait_method_on_a_type_variable.stderr @@ -7,9 +7,9 @@ error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, w = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> data_decode__a_closure_passes_its_type_to_a_trait_method_on_a_type_variable.silt:40:31 + --> data_decode__a_closure_passes_its_type_to_a_trait_method_on_a_type_variable.silt:40:39 | - 40 | let _ = src.load_by_closure(Blob) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 40 | let _ = Loader.load_by_closure(src, Blob) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `Src.load_by_closure` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these diff --git a/tests/golden/lang/stdlib/data_decode__a_field_with_no_decoder_is_refused_when_its_key_is_absent.silt b/tests/golden/lang/stdlib/data_decode__a_field_with_no_decoder_is_refused_when_its_key_is_absent.silt index d5c18787f..4e4704ac1 100644 --- a/tests/golden/lang/stdlib/data_decode__a_field_with_no_decoder_is_refused_when_its_key_is_absent.silt +++ b/tests/golden/lang/stdlib/data_decode__a_field_with_no_decoder_is_refused_when_its_key_is_absent.silt @@ -22,7 +22,7 @@ fn from_toml(text: String, type a) -> Result(a, toml.TomlError) { fn show(r: Result(a, e)) where e: Error { match r { Ok(_) -> println("ok") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/stdlib/data_decode__a_json_value_field_has_no_toml_decoder_whatever_the_document_holds.silt b/tests/golden/lang/stdlib/data_decode__a_json_value_field_has_no_toml_decoder_whatever_the_document_holds.silt index 68223bf3b..27eaa2089 100644 --- a/tests/golden/lang/stdlib/data_decode__a_json_value_field_has_no_toml_decoder_whatever_the_document_holds.silt +++ b/tests/golden/lang/stdlib/data_decode__a_json_value_field_has_no_toml_decoder_whatever_the_document_holds.silt @@ -26,7 +26,7 @@ fn from_toml(text: String, type a) -> Result(a, toml.TomlError) { fn show(r: Result(a, e)) where e: Error { match r { Ok(_) -> println("ok") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/stdlib/data_decode__a_record_type_a_field_names_is_looked_into_for_a_field_with_no_decoder.silt b/tests/golden/lang/stdlib/data_decode__a_record_type_a_field_names_is_looked_into_for_a_field_with_no_decoder.silt index a57e6d39b..26cbe59e2 100644 --- a/tests/golden/lang/stdlib/data_decode__a_record_type_a_field_names_is_looked_into_for_a_field_with_no_decoder.silt +++ b/tests/golden/lang/stdlib/data_decode__a_record_type_a_field_names_is_looked_into_for_a_field_with_no_decoder.silt @@ -24,7 +24,7 @@ fn from_toml(text: String, type a) -> Result(a, toml.TomlError) { fn show(r: Result(a, e)) where e: Error { match r { Ok(_) -> println("ok") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/case.stderr b/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/case.stderr index 20a4ff232..62b2d48f0 100644 --- a/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/case.stderr +++ b/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/case.stderr @@ -1,23 +1,23 @@ error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> main.silt:14:18 + --> main.silt:14:26 | - 14 | println(s.load(Blob)) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 14 | println(Loader.load(s, Blob)) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `Src.load` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> main.silt:15:17 + --> main.silt:15:25 | - 15 | println(s.own(Blob)) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 15 | println(Loader.own(s, Blob)) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `Src.own` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> main.silt:16:26 + --> main.silt:16:25 | - 16 | println(src.Src.own(s, Blob)) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 16 | println(Loader.own(s, Blob)) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `Src.own` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these diff --git a/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/loader.silt b/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/loader.silt index fa02cf499..a72dd052b 100644 --- a/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/loader.silt +++ b/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/loader.silt @@ -3,7 +3,7 @@ import json pub trait Loader { fn text(self) -> String fn load(self, type a) -> Result(a, json.JsonError) where a: json.Decode { - json.parse(self.text(), a) + json.parse(Loader.text(self), a) } fn own(self, type a) -> Result(a, json.JsonError) where a: json.Decode } diff --git a/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/main.silt b/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/main.silt index 1a1cc3757..81fdc82bf 100644 --- a/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/main.silt +++ b/tests/golden/lang/stdlib/data_decode__a_trait_method_of_another_module_passes_its_type_on/main.silt @@ -11,7 +11,7 @@ type Blob { data: Bytes } fn main() { let s = src.Src { s: "\{}" } - println(s.load(Blob)) - println(s.own(Blob)) - println(src.Src.own(s, Blob)) + println(Loader.load(s, Blob)) + println(Loader.own(s, Blob)) + println(Loader.own(s, Blob)) } diff --git a/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_of_another_module/generic.silt b/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_of_another_module/generic.silt index 7a3fa851d..3f120057a 100644 --- a/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_of_another_module/generic.silt +++ b/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_of_another_module/generic.silt @@ -2,5 +2,5 @@ import json import source.{ Loader } pub fn fetch(l: l, type b) -> Result(b, json.JsonError) where l: Loader, b: json.Decode { - l.load_again(b) + Loader.load_again(l, b) } diff --git a/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_of_another_module/source.silt b/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_of_another_module/source.silt index 867c9a04c..a73d3c2b1 100644 --- a/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_of_another_module/source.silt +++ b/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_of_another_module/source.silt @@ -3,7 +3,7 @@ import json pub trait Loader { fn load(self, type a) -> Result(a, json.JsonError) where a: json.Decode fn load_again(self, type a) -> Result(a, json.JsonError) where a: json.Decode { - self.load(a) + Loader.load(self, a) } } diff --git a/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.silt b/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.silt index 217785ce1..34c5d222a 100644 --- a/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.silt +++ b/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.silt @@ -16,10 +16,10 @@ trait Loader { fn text(self) -> String fn load(self, type a) -> Result(a, json.JsonError) where a: json.Decode fn load_via_load(self, type a) -> Result(a, json.JsonError) where a: json.Decode { - self.load(a) + Loader.load(self, a) } fn load_twice(self, type a) -> Result(a, json.JsonError) where a: json.Decode { - self.load_via_load(a) + Loader.load_via_load(self, a) } } @@ -34,15 +34,15 @@ trait Loader for Src { trait Loader for Box(t) where t: Loader { fn text(self) -> String { - self.inner.text() + Loader.text(self.inner) } fn load(self, type a) -> Result(a, json.JsonError) { - self.inner.load(a) + Loader.load(self.inner, a) } } fn go(l: l, type b) -> Result(b, json.JsonError) where l: Loader, b: json.Decode { - l.load(b) + Loader.load(l, b) } fn go2(l: l, type b) -> Result(b, json.JsonError) where l: Loader, b: json.Decode { @@ -50,7 +50,7 @@ fn go2(l: l, type b) -> Result(b, json.JsonError) where l: Loader, b: json.Decod } fn go3(l, b) { - l.load(b) + Loader.load(l, b) } fn generic_all_the_way(l: l, type b) -> Result(b, json.JsonError) where l: Loader, b: json.Decode { @@ -63,8 +63,8 @@ fn main() { let _ = go(src, Blob) let _ = go2(src, Blob) let _ = go3(src, Blob) - let _ = src.load_via_load(Blob) - let _ = src.load_twice(Blob) - let _ = Box { inner: src }.load(Blob) + let _ = Loader.load_via_load(src, Blob) + let _ = Loader.load_twice(src, Blob) + let _ = Loader.load(Box { inner: src }, Blob) let _ = go(Box { inner: Box { inner: src } }, Blob) } diff --git a/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.stderr b/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.stderr index a9b260a52..ef9826097 100644 --- a/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.stderr +++ b/tests/golden/lang/stdlib/data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.stderr @@ -23,26 +23,26 @@ error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, w = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.silt:66:29 + --> data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.silt:66:37 | - 66 | let _ = src.load_via_load(Blob) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 66 | let _ = Loader.load_via_load(src, Blob) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `Src.load_via_load` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.silt:67:26 + --> data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.silt:67:34 | - 67 | let _ = src.load_twice(Blob) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 67 | let _ = Loader.load_twice(src, Blob) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `Src.load_twice` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.silt:68:35 + --> data_decode__a_trait_method_on_a_type_variable_passes_its_type_on.silt:68:43 | - 68 | let _ = Box { inner: src }.load(Blob) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 68 | let _ = Loader.load(Box { inner: src }, Blob) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `Box.load` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these diff --git a/tests/golden/lang/stdlib/data_decode__a_trait_method_passes_its_type_on.silt b/tests/golden/lang/stdlib/data_decode__a_trait_method_passes_its_type_on.silt index e8c838c89..832702f08 100644 --- a/tests/golden/lang/stdlib/data_decode__a_trait_method_passes_its_type_on.silt +++ b/tests/golden/lang/stdlib/data_decode__a_trait_method_passes_its_type_on.silt @@ -15,7 +15,7 @@ trait Loader { fn text(self) -> String fn load(self, type a) -> Result(a, json.JsonError) where a: json.Decode fn load_text(self, type a) -> Result(a, json.JsonError) where a: json.Decode { - json.parse(self.text(), a) + json.parse(Loader.text(self), a) } } @@ -29,14 +29,14 @@ trait Loader for Src { } fn via(src: Src, type a) -> Result(a, json.JsonError) where a: json.Decode { - src.load(a) + Loader.load(src, a) } fn main() { let src = Src { s: "\{\"n\": 1}" } - let _ = src.load(Fine) - let _ = src.load(Blob) - let _ = src.load_text(Blob) - let _ = Src.load(src, Blob) + let _ = Loader.load(src, Fine) + let _ = Loader.load(src, Blob) + let _ = Loader.load_text(src, Blob) + let _ = Loader.load(src, Blob) let _ = via(src, Blob) } diff --git a/tests/golden/lang/stdlib/data_decode__a_trait_method_passes_its_type_on.stderr b/tests/golden/lang/stdlib/data_decode__a_trait_method_passes_its_type_on.stderr index 18909781f..727f2bc95 100644 --- a/tests/golden/lang/stdlib/data_decode__a_trait_method_passes_its_type_on.stderr +++ b/tests/golden/lang/stdlib/data_decode__a_trait_method_passes_its_type_on.stderr @@ -1,24 +1,24 @@ error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> data_decode__a_trait_method_passes_its_type_on.silt:38:20 + --> data_decode__a_trait_method_passes_its_type_on.silt:38:28 | - 38 | let _ = src.load(Blob) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 38 | let _ = Loader.load(src, Blob) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `Src.load` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> data_decode__a_trait_method_passes_its_type_on.silt:39:25 + --> data_decode__a_trait_method_passes_its_type_on.silt:39:33 | - 39 | let _ = src.load_text(Blob) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 39 | let _ = Loader.load_text(src, Blob) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `Src.load_text` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> data_decode__a_trait_method_passes_its_type_on.silt:40:25 + --> data_decode__a_trait_method_passes_its_type_on.silt:40:28 | - 40 | let _ = Src.load(src, Blob) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 40 | let _ = Loader.load(src, Blob) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `Src.load` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these diff --git a/tests/golden/lang/stdlib/data_decode__a_type_given_through_reordered_trait_method_type_arguments_is_named_as_through_a_function/lib.silt b/tests/golden/lang/stdlib/data_decode__a_type_given_through_reordered_trait_method_type_arguments_is_named_as_through_a_function/lib.silt index f07417afe..2820b1459 100644 --- a/tests/golden/lang/stdlib/data_decode__a_type_given_through_reordered_trait_method_type_arguments_is_named_as_through_a_function/lib.silt +++ b/tests/golden/lang/stdlib/data_decode__a_type_given_through_reordered_trait_method_type_arguments_is_named_as_through_a_function/lib.silt @@ -21,7 +21,7 @@ pub fn rev(x: s, type a, type b, type c) a: json.Decode, b: json.Decode, c: json.Decode { - x.get(c, b, a) + Three.get(x, c, b, a) } pub fn swap(x: s, type a, type b, type c) @@ -34,8 +34,8 @@ pub fn swap(x: s, type a, type b, type c) } pub fn twice(x: s, type a, type b) where s: Three, a: json.Decode, b: json.Decode { - x.get(b, a, a) - x.get(a, a, b) + Three.get(x, b, a, a) + Three.get(x, a, a, b) } pub fn direct(type a, type b, type c) where a: json.Decode, b: json.Decode, c: json.Decode { diff --git a/tests/golden/lang/stdlib/data_decode__a_type_with_no_decoder_is_refused_before_the_document_is_read.silt b/tests/golden/lang/stdlib/data_decode__a_type_with_no_decoder_is_refused_before_the_document_is_read.silt index 2a24e47d5..17123c366 100644 --- a/tests/golden/lang/stdlib/data_decode__a_type_with_no_decoder_is_refused_before_the_document_is_read.silt +++ b/tests/golden/lang/stdlib/data_decode__a_type_with_no_decoder_is_refused_before_the_document_is_read.silt @@ -25,7 +25,7 @@ fn from_toml(text: String, type a) -> Result(a, toml.TomlError) { fn show(r: Result(a, e)) where e: Error { match r { Ok(_) -> println("ok") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/stdlib/data_decode__aliases_given_through_a_trait_method_with_two_type_arguments_are_named_at_their_places/lib.silt b/tests/golden/lang/stdlib/data_decode__aliases_given_through_a_trait_method_with_two_type_arguments_are_named_at_their_places/lib.silt index 5cbca1983..fee0a27e2 100644 --- a/tests/golden/lang/stdlib/data_decode__aliases_given_through_a_trait_method_with_two_type_arguments_are_named_at_their_places/lib.silt +++ b/tests/golden/lang/stdlib/data_decode__aliases_given_through_a_trait_method_with_two_type_arguments_are_named_at_their_places/lib.silt @@ -17,7 +17,7 @@ trait Two for T { } pub fn via(x: s, type a, type b) where s: Two, a: json.Decode, b: json.Decode { - x.get(a, b) + Two.get(x, a, b) } pub fn direct(type a, type b) where a: json.Decode, b: json.Decode { @@ -26,11 +26,11 @@ pub fn direct(type a, type b) where a: json.Decode, b: json.Decode { } pub fn fixed(x: s, type b) where s: Two, b: json.Decode { - x.get(Int, b) + Two.get(x, Int, b) } pub fn pair(x: s, p: (a, b), type a, type b) where s: Two, a: json.Decode, b: json.Decode { - x.get(a, b) + Two.get(x, a, b) } pub fn dpair(p: (a, b), type a, type b) where a: json.Decode, b: json.Decode { @@ -38,7 +38,7 @@ pub fn dpair(p: (a, b), type a, type b) where a: json.Decode, b: json.Decode { } pub fn first(p: (b, a), x: s, type a, type b) where s: Two, a: json.Decode, b: json.Decode { - x.get(a, b) + Two.get(x, a, b) } pub fn dfirst(p: (b, a), type a, type b) where a: json.Decode, b: json.Decode { @@ -46,8 +46,8 @@ pub fn dfirst(p: (b, a), type a, type b) where a: json.Decode, b: json.Decode { } pub fn twice(x: s, type a, type b) where s: Two, a: json.Decode, b: json.Decode { - x.get(b, b) - x.get(a, a) + Two.get(x, b, b) + Two.get(x, a, a) } pub fn dtwice(type a, type b) where a: json.Decode, b: json.Decode { @@ -56,7 +56,7 @@ pub fn dtwice(type a, type b) where a: json.Decode, b: json.Decode { } pub fn own(x: s, type a) where s: Two, a: json.Decode { - x.get(Int, Int) + Two.get(x, Int, Int) } pub fn down(type a) where a: json.Decode { diff --git a/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/case.stderr b/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/case.stderr index 6bc95c740..9de4609b4 100644 --- a/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/case.stderr +++ b/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/case.stderr @@ -15,10 +15,10 @@ error[type]: `toml.parse` cannot decode `L`: its type argument must be a record = help: use `toml.parse_list` for a list error[type]: `toml.parse` cannot decode `L`: its type argument must be a record type, an enum type, or a type with a `json.Decode` impl - --> main.silt:30:31 + --> main.silt:30:41 | - 30 | lib.T { n: 1 }.get("n = 1", L) - | ^ `toml.parse` cannot decode `L`: its type argument must be a record type, an enum type, or a type with a `json.Decode` impl + 30 | lib.Load.get(lib.T { n: 1 }, "n = 1", L) + | ^ `toml.parse` cannot decode `L`: its type argument must be a record type, an enum type, or a type with a `json.Decode` impl = note: `T.get` passes it to `toml.parse` = help: use `toml.parse_list` for a list diff --git a/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/lib.silt b/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/lib.silt index 9bb9b8194..bf602d06f 100644 --- a/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/lib.silt +++ b/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/lib.silt @@ -16,7 +16,7 @@ trait Load for T { } pub fn via(x: s, type a) where s: Load, a: json.Decode { - x.get("n = 1", a) + Load.get(x, "n = 1", a) } pub fn deep(x: s, type a) where s: Load, a: json.Decode { diff --git a/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/main.silt b/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/main.silt index a08205f40..174567106 100644 --- a/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/main.silt +++ b/tests/golden/lang/stdlib/data_decode__an_alias_given_through_a_trait_method_of_another_module_is_named_as_written/main.silt @@ -27,7 +27,7 @@ type RA = Raw fn main() { lib.via(lib.T { n: 1 }, L) lib.direct("n = 1", L) - lib.T { n: 1 }.get("n = 1", L) + lib.Load.get(lib.T { n: 1 }, "n = 1", L) lib.deep(lib.T { n: 1 }, L) lib.via(lib.T { n: 1 }, LL) lib.via(lib.T { n: 1 }, NL) diff --git a/tests/golden/lang/stdlib/data_decode__an_empty_document_does_not_hide_a_field_with_no_decoder.silt b/tests/golden/lang/stdlib/data_decode__an_empty_document_does_not_hide_a_field_with_no_decoder.silt index 270f00aec..03ff1fcdc 100644 --- a/tests/golden/lang/stdlib/data_decode__an_empty_document_does_not_hide_a_field_with_no_decoder.silt +++ b/tests/golden/lang/stdlib/data_decode__an_empty_document_does_not_hide_a_field_with_no_decoder.silt @@ -25,7 +25,7 @@ fn toml_list(text: String, type a) -> Result(List(a), toml.TomlError) { fn show(r: Result(a, e)) where e: Error { match r { Ok(_) -> println("ok") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/stdlib/data_decode__closures_and_receivers_of_one_shape_pass_their_type_on.silt b/tests/golden/lang/stdlib/data_decode__closures_and_receivers_of_one_shape_pass_their_type_on.silt index ac30aa530..9b6bb64ec 100644 --- a/tests/golden/lang/stdlib/data_decode__closures_and_receivers_of_one_shape_pass_their_type_on.silt +++ b/tests/golden/lang/stdlib/data_decode__closures_and_receivers_of_one_shape_pass_their_type_on.silt @@ -33,29 +33,29 @@ trait Loader for Other { trait Loader for Box(t) where t: Loader { fn load(self, type a) -> Result(a, json.JsonError) { - self.v.load(a) + Loader.load(self.v, a) } } fn both(x, y, t) { - let _ = Box { v: x }.load(t) - Box { v: y }.load(t) + let _ = Loader.load(Box { v: x }, t) + Loader.load(Box { v: y }, t) } fn go(l, t) { - l.load(t) + Loader.load(l, t) } fn go_annotated(l: l, type b) -> Result(b, json.JsonError) where l: Loader, b: json.Decode { - l.load(b) + Loader.load(l, b) } fn returned(l) { - { t -> l.load(t) } + { t -> Loader.load(l, t) } } fn kept(l) { - H { f: { t -> l.load(t) } } + H { f: { t -> Loader.load(l, t) } } } fn apply1(f, t) { @@ -76,5 +76,5 @@ fn main() { let _ = g(Blob) let h = kept(src) let _ = h.f(Blob) - let _ = apply1({ t -> src.load(t) }, Blob) + let _ = apply1({ t -> Loader.load(src, t) }, Blob) } diff --git a/tests/golden/lang/stdlib/data_decode__closures_and_receivers_of_one_shape_pass_their_type_on.stderr b/tests/golden/lang/stdlib/data_decode__closures_and_receivers_of_one_shape_pass_their_type_on.stderr index 710cd127d..0720c1b92 100644 --- a/tests/golden/lang/stdlib/data_decode__closures_and_receivers_of_one_shape_pass_their_type_on.stderr +++ b/tests/golden/lang/stdlib/data_decode__closures_and_receivers_of_one_shape_pass_their_type_on.stderr @@ -45,9 +45,9 @@ error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, w = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these error[type]: `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder - --> data_decode__closures_and_receivers_of_one_shape_pass_their_type_on.silt:79:40 + --> data_decode__closures_and_receivers_of_one_shape_pass_their_type_on.silt:79:48 | - 79 | let _ = apply1({ t -> src.load(t) }, Blob) - | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder + 79 | let _ = apply1({ t -> Loader.load(src, t) }, Blob) + | ^^^^ `json.parse` cannot decode `Blob`: field `data` has type `Bytes`, which has no decoder = note: `apply1` passes it to `json.parse` = help: decodable field types are Int, Float, String, Bool, time.Date, time.Time, time.DateTime, json.Value, List(T), Option(T), Map(String, T), tuples, non-generic record and enum types, types with a `json.Decode` impl, and aliases of these diff --git a/tests/golden/lang/stdlib/data_write__record_fields_in_declaration_order.silt b/tests/golden/lang/stdlib/data_write__record_fields_in_declaration_order.silt index 5a98388af..66767dacc 100644 --- a/tests/golden/lang/stdlib/data_write__record_fields_in_declaration_order.silt +++ b/tests/golden/lang/stdlib/data_write__record_fields_in_declaration_order.silt @@ -32,11 +32,11 @@ fn main() { println(json.pretty(Point { y: 2, x: 1 })) match toml.stringify(shape) { Ok(text) -> print(text) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match toml.pretty(shape) { Ok(text) -> print(text) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } println(json.stringify(#{ 9: "nine", 10: "ten" })) println(json.stringify(json.Object(#{ "b": json.Int(1), "a": json.Int(2) }))) diff --git a/tests/golden/lang/stdlib/json_syntax__the_offset_counts_bytes_from_the_start_of_the_text.silt b/tests/golden/lang/stdlib/json_syntax__the_offset_counts_bytes_from_the_start_of_the_text.silt index 86c5b5b54..fc8d42359 100644 --- a/tests/golden/lang/stdlib/json_syntax__the_offset_counts_bytes_from_the_start_of_the_text.silt +++ b/tests/golden/lang/stdlib/json_syntax__the_offset_counts_bytes_from_the_start_of_the_text.silt @@ -8,7 +8,7 @@ fn show(text: String) { match json.parse(text, json.Value) { Ok(_) -> println("ok") Err(json.Syntax(message, at)) -> println("byte {at}: {message}") - Err(e) -> println("other: {e.message()}") + Err(e) -> println("other: {Error.message(e)}") } } diff --git a/tests/golden/lang/stdlib/toml_module__toml_parse_missing_required_field_error.silt b/tests/golden/lang/stdlib/toml_module__toml_parse_missing_required_field_error.silt index 5ad613098..95fcb3a57 100644 --- a/tests/golden/lang/stdlib/toml_module__toml_parse_missing_required_field_error.silt +++ b/tests/golden/lang/stdlib/toml_module__toml_parse_missing_required_field_error.silt @@ -5,7 +5,7 @@ fn run_main() { match toml.parse(input, User) { Ok(_) -> "unexpected" Err(toml.MissingField(f)) -> f - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/lang/stdlib/toml_module__toml_parse_type_mismatch_names_field.silt b/tests/golden/lang/stdlib/toml_module__toml_parse_type_mismatch_names_field.silt index e1ad59cc4..eeeb057bf 100644 --- a/tests/golden/lang/stdlib/toml_module__toml_parse_type_mismatch_names_field.silt +++ b/tests/golden/lang/stdlib/toml_module__toml_parse_type_mismatch_names_field.silt @@ -6,7 +6,7 @@ fn run_main() { match toml.parse(input, User) { Ok(_) -> "unexpected" Err(toml.TypeMismatch(expected, actual)) -> "{expected}/{actual}" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/lang/tasks/call_method_yield__trait_method_in_spawned_task/main.silt b/tests/golden/lang/tasks/call_method_yield__trait_method_in_spawned_task/main.silt index b027a6b6c..ed5d7a6ad 100644 --- a/tests/golden/lang/tasks/call_method_yield__trait_method_in_spawned_task/main.silt +++ b/tests/golden/lang/tasks/call_method_yield__trait_method_in_spawned_task/main.silt @@ -19,7 +19,7 @@ trait Greet for Greeter { fn main() { let g = Greeter { path: "greeting.txt" } let handle = task.spawn({ -> - let msg = g.greet() + let msg = Greet.greet(g) msg }) println(task.join(handle)) diff --git a/tests/golden/lang/tasks/indirect_builtin_call__direct_read_file_in_spawned_task.silt b/tests/golden/lang/tasks/indirect_builtin_call__direct_read_file_in_spawned_task.silt index 142fba5a7..15530e710 100644 --- a/tests/golden/lang/tasks/indirect_builtin_call__direct_read_file_in_spawned_task.silt +++ b/tests/golden/lang/tasks/indirect_builtin_call__direct_read_file_in_spawned_task.silt @@ -8,6 +8,6 @@ fn main() { let h = task.spawn({ -> io.read_file("indirect_builtin_call__direct_read_file_in_spawned_task.silt") }) match task.join(h) { Ok(s) -> println(string.contains(s, "-- direct call")) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/tasks/indirect_builtin_call__indirect_read_file_in_spawned_task.silt b/tests/golden/lang/tasks/indirect_builtin_call__indirect_read_file_in_spawned_task.silt index 1a08670b4..cf6846e4f 100644 --- a/tests/golden/lang/tasks/indirect_builtin_call__indirect_read_file_in_spawned_task.silt +++ b/tests/golden/lang/tasks/indirect_builtin_call__indirect_read_file_in_spawned_task.silt @@ -11,6 +11,6 @@ fn main() { let h = task.spawn({ -> read("indirect_builtin_call__indirect_read_file_in_spawned_task.silt") }) match task.join(h) { Ok(s) -> println(string.contains(s, "-- hello from indirect")) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/tasks/indirect_builtin_call__indirect_write_file_in_spawned_task.silt b/tests/golden/lang/tasks/indirect_builtin_call__indirect_write_file_in_spawned_task.silt index 81107abd8..7045a322a 100644 --- a/tests/golden/lang/tasks/indirect_builtin_call__indirect_write_file_in_spawned_task.silt +++ b/tests/golden/lang/tasks/indirect_builtin_call__indirect_write_file_in_spawned_task.silt @@ -8,10 +8,10 @@ fn main() { let h = task.spawn({ -> write("indirect_write.txt", "written indirectly") }) match task.join(h) { Ok(_) -> println("ok") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } match io.read_file("indirect_write.txt") { Ok(s) -> println(s) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/tasks/round77_callmethod_resume__qualified_global_method_runs_once.silt b/tests/golden/lang/tasks/round77_callmethod_resume__qualified_global_method_runs_once.silt index 8b9ab2b94..fb06a3b4e 100644 --- a/tests/golden/lang/tasks/round77_callmethod_resume__qualified_global_method_runs_once.silt +++ b/tests/golden/lang/tasks/round77_callmethod_resume__qualified_global_method_runs_once.silt @@ -17,7 +17,7 @@ trait Counter for Int { fn main() { let h = task.spawn({ -> let n = 7 - n.bump() + Counter.bump(n) }) println(task.join(h)) } diff --git a/tests/golden/lang/tasks/round78_io_yield_helper__write_file_in_task_persists.silt b/tests/golden/lang/tasks/round78_io_yield_helper__write_file_in_task_persists.silt index edc3dd2bd..33c9eff97 100644 --- a/tests/golden/lang/tasks/round78_io_yield_helper__write_file_in_task_persists.silt +++ b/tests/golden/lang/tasks/round78_io_yield_helper__write_file_in_task_persists.silt @@ -13,6 +13,6 @@ fn main() { task.join(h) match io.read_file("round78_write.txt") { Ok(s) -> println(s) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/lang/tasks/wave1_vm__guard_v2_many_calls_in_sequence_are_not_depth.silt b/tests/golden/lang/tasks/wave1_vm__guard_v2_many_calls_in_sequence_are_not_depth.silt index 082bef521..085e76817 100644 --- a/tests/golden/lang/tasks/wave1_vm__guard_v2_many_calls_in_sequence_are_not_depth.silt +++ b/tests/golden/lang/tasks/wave1_vm__guard_v2_many_calls_in_sequence_are_not_depth.silt @@ -6,13 +6,13 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } fn wide() { - list.fold(1..5000, 0) { acc, x -> acc + 3.go() } + list.fold(1..5000, 0) { acc, x -> acc + Deep.go(3) } } fn main() { println("main {wide()}") diff --git a/tests/golden/lang/tasks/wave1_vm__guard_v2_moderate_recursion_in_a_task.silt b/tests/golden/lang/tasks/wave1_vm__guard_v2_moderate_recursion_in_a_task.silt index a12d39539..02be5c13f 100644 --- a/tests/golden/lang/tasks/wave1_vm__guard_v2_moderate_recursion_in_a_task.silt +++ b/tests/golden/lang/tasks/wave1_vm__guard_v2_moderate_recursion_in_a_task.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } @@ -21,7 +21,7 @@ fn deep(n) { } fn main() { - let a = task.spawn { -> 6.go() } + let a = task.spawn { -> Deep.go(6) } let b = task.spawn { -> deep(6) } println("method {task.join(a)}") println("fold {task.join(b)}") diff --git a/tests/golden/lang/tasks/wave1_vm__guard_v2_moderate_recursion_on_the_main_thread.silt b/tests/golden/lang/tasks/wave1_vm__guard_v2_moderate_recursion_on_the_main_thread.silt index a62763377..e49091e28 100644 --- a/tests/golden/lang/tasks/wave1_vm__guard_v2_moderate_recursion_on_the_main_thread.silt +++ b/tests/golden/lang/tasks/wave1_vm__guard_v2_moderate_recursion_on_the_main_thread.silt @@ -5,7 +5,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } @@ -19,6 +19,6 @@ fn deep(n) { } fn main() { - println("method {500.go()}") + println("method {Deep.go(500)}") println("fold {deep(500)}") } diff --git a/tests/golden/lang/tasks/wave1_vm__v2_a_test_run_continues_after_the_overflow.silt b/tests/golden/lang/tasks/wave1_vm__v2_a_test_run_continues_after_the_overflow.silt index d398bbf73..117d4b6af 100644 --- a/tests/golden/lang/tasks/wave1_vm__v2_a_test_run_continues_after_the_overflow.silt +++ b/tests/golden/lang/tasks/wave1_vm__v2_a_test_run_continues_after_the_overflow.silt @@ -12,14 +12,14 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } fn test_a_recursion_far_beyond_the_budget() { - test.assert_eq(200000.go(), 200000) + test.assert_eq(Deep.go(200000), 200000) } fn test_b_moderate_recursion_afterwards() { - test.assert_eq(500.go(), 500) + test.assert_eq(Deep.go(500), 500) } diff --git a/tests/golden/lang/tasks/wave1_vm__v2_method_recursion_in_a_task_ends_in_a_runtime_error.silt b/tests/golden/lang/tasks/wave1_vm__v2_method_recursion_in_a_task_ends_in_a_runtime_error.silt index 42df69c5e..23ebedff4 100644 --- a/tests/golden/lang/tasks/wave1_vm__v2_method_recursion_in_a_task_ends_in_a_runtime_error.silt +++ b/tests/golden/lang/tasks/wave1_vm__v2_method_recursion_in_a_task_ends_in_a_runtime_error.silt @@ -9,12 +9,12 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } fn main() { - let t = task.spawn { -> 200000.go() } + let t = task.spawn { -> Deep.go(200000) } println(task.join(t)) } diff --git a/tests/golden/lang/tasks/wave1_vm__v2_method_recursion_on_the_main_thread_ends_in_a_runtime_error.silt b/tests/golden/lang/tasks/wave1_vm__v2_method_recursion_on_the_main_thread_ends_in_a_runtime_error.silt index d6eb43a12..32ddb167f 100644 --- a/tests/golden/lang/tasks/wave1_vm__v2_method_recursion_on_the_main_thread_ends_in_a_runtime_error.silt +++ b/tests/golden/lang/tasks/wave1_vm__v2_method_recursion_on_the_main_thread_ends_in_a_runtime_error.silt @@ -7,11 +7,11 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } fn main() { - println(200000.go()) + println(Deep.go(200000)) } diff --git a/tests/golden/lang/tcp/conventions__a_tcp_failure_is_named_after_what_failed.silt b/tests/golden/lang/tcp/conventions__a_tcp_failure_is_named_after_what_failed.silt index 89e80379b..639d677a5 100644 --- a/tests/golden/lang/tcp/conventions__a_tcp_failure_is_named_after_what_failed.silt +++ b/tests/golden/lang/tcp/conventions__a_tcp_failure_is_named_after_what_failed.silt @@ -24,7 +24,7 @@ fn main() { Ok(_) -> println("nobody listens, and yet connected") } match tcp.listen("127.0.0.1:{port}") { - Err(e) -> println(e.message() != "") + Err(e) -> println(Error.message(e) != "") Ok(_) -> println("bound") } } diff --git a/tests/golden/lang/tcp_tls/tls_server__a_pem_that_does_not_parse_says_why.silt b/tests/golden/lang/tcp_tls/tls_server__a_pem_that_does_not_parse_says_why.silt index 78d206c90..22a110667 100644 --- a/tests/golden/lang/tcp_tls/tls_server__a_pem_that_does_not_parse_says_why.silt +++ b/tests/golden/lang/tcp_tls/tls_server__a_pem_that_does_not_parse_says_why.silt @@ -10,7 +10,7 @@ fn attempt(listener, addr, cert_text) { let cert = bytes.from_string(cert_text) match tcp.tls_server(conn, cert, bytes.from_string("not a key")) { Ok(_) -> println("a TLS connection") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } tcp.close(client) } diff --git a/tests/golden/lang/tcp_tls/tls_server__takes_the_connection.silt b/tests/golden/lang/tcp_tls/tls_server__takes_the_connection.silt index 544966dda..3b92cc0e2 100644 --- a/tests/golden/lang/tcp_tls/tls_server__takes_the_connection.silt +++ b/tests/golden/lang/tcp_tls/tls_server__takes_the_connection.silt @@ -16,23 +16,23 @@ fn main() { let key = bytes.from_string("not a key") match tcp.tls_server(conn, cert, key) { Ok(_) -> println("a TLS connection") - Err(e) -> println("tls_server: {e.message()}") + Err(e) -> println("tls_server: {Error.message(e)}") } match tcp.read(conn, 1) { Ok(_) -> println("the taken connection reads") - Err(e) -> println("read of the taken connection: {e.message()}") + Err(e) -> println("read of the taken connection: {Error.message(e)}") } match tcp.write(conn, bytes.from_string("x")) { Ok(_) -> println("the taken connection writes") - Err(e) -> println("write of the taken connection: {e.message()}") + Err(e) -> println("write of the taken connection: {Error.message(e)}") } match tcp.tls_server(conn, cert, key) { Ok(_) -> println("a TLS connection") - Err(e) -> println("tls_server again: {e.message()}") + Err(e) -> println("tls_server again: {Error.message(e)}") } match tcp.read(client, 1) { Ok(data) -> println("the client reads {bytes.length(data)} bytes") - Err(e) -> println("the client's read fails: {e.message()}") + Err(e) -> println("the client's read fails: {Error.message(e)}") } -- A connection closed before the call. when let Ok(other) = tcp.connect(addr) else { panic("cannot connect") } @@ -40,7 +40,7 @@ fn main() { tcp.close(closed) match tcp.tls_server(closed, cert, key) { Ok(_) -> println("a TLS connection") - Err(e) -> println("tls_server of a closed connection: {e.message()}") + Err(e) -> println("tls_server of a closed connection: {Error.message(e)}") } tcp.close(other) } diff --git a/tests/golden/lang/time/time_builtin_bounds__format_date_rejects_time_only_specifier.silt b/tests/golden/lang/time/time_builtin_bounds__format_date_rejects_time_only_specifier.silt index 7f608cf1f..f3bdbcec0 100644 --- a/tests/golden/lang/time/time_builtin_bounds__format_date_rejects_time_only_specifier.silt +++ b/tests/golden/lang/time/time_builtin_bounds__format_date_rejects_time_only_specifier.silt @@ -7,7 +7,7 @@ fn day() -> time.Date { } fn main() { match time.format_date(day(), "%H") { - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) Ok(text) -> println("formatted: {text}") } } diff --git a/tests/golden/lang/time/time_builtin_bounds__format_date_rejects_timezone_specifier.silt b/tests/golden/lang/time/time_builtin_bounds__format_date_rejects_timezone_specifier.silt index 9ab2422cb..314031dcb 100644 --- a/tests/golden/lang/time/time_builtin_bounds__format_date_rejects_timezone_specifier.silt +++ b/tests/golden/lang/time/time_builtin_bounds__format_date_rejects_timezone_specifier.silt @@ -7,7 +7,7 @@ fn day() -> time.Date { } fn main() { match time.format_date(day(), "%z") { - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) Ok(text) -> println("formatted: {text}") } } diff --git a/tests/golden/lang/time/time_builtin_bounds__format_rejects_timezone_specifier_naive_datetime.silt b/tests/golden/lang/time/time_builtin_bounds__format_rejects_timezone_specifier_naive_datetime.silt index 16c5184c3..19f51bedd 100644 --- a/tests/golden/lang/time/time_builtin_bounds__format_rejects_timezone_specifier_naive_datetime.silt +++ b/tests/golden/lang/time/time_builtin_bounds__format_rejects_timezone_specifier_naive_datetime.silt @@ -8,7 +8,7 @@ fn day() -> time.Date { fn main() { let t = time.Time { hour: 10, minute: 30, second: 0, ns: 0 } match time.format(time.datetime(day(), t), "%z") { - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) Ok(text) -> println("formatted: {text}") } } diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__date_compare.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__date_compare.silt index a2f909d69..26161d808 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__date_compare.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__date_compare.silt @@ -1,5 +1,5 @@ import time -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { match time.date(2025, 1, 15) { Ok(early) -> match time.date(2025, 6, 30) { diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__date_direct_compare.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__date_direct_compare.silt index f887dbbcc..544796324 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__date_direct_compare.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__date_direct_compare.silt @@ -3,9 +3,9 @@ fn main() { match time.date(2025, 1, 15) { Ok(a) -> match time.date(2025, 1, 20) { Ok(b) -> { - println(a.compare(b)) - println(b.compare(a)) - println(a.compare(a)) + println(Compare.compare(a, b)) + println(Compare.compare(b, a)) + println(Compare.compare(a, a)) } Err(_) -> () } diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__date_display.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__date_display.silt index 4c34676b5..56fbb4e5e 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__date_display.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__date_display.silt @@ -1,5 +1,5 @@ import time -fn d(a: a) -> String where a: Display { a.display() } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { match time.date(2025, 1, 15) { Ok(date) -> println(d(date)) diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__datetime_equal.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__datetime_equal.silt index 741ff9eb8..7971c33df 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__datetime_equal.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__datetime_equal.silt @@ -1,5 +1,5 @@ import time -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } fn main() { match time.date(2025, 1, 15) { Ok(d1) -> match time.time(8, 30, 0) { diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__http_method_compare.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__http_method_compare.silt index 589a3a389..e250acd1f 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__http_method_compare.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__http_method_compare.silt @@ -1,3 +1,3 @@ import http -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(http.GET, http.POST)) } diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__option_display.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__option_display.silt index c2eeae242..bc1628c1d 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__option_display.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__option_display.silt @@ -1,4 +1,4 @@ -fn d(a: a) -> String where a: Display { a.display() } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { println(d(Some(42))) let n: Option(Int) = None diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__parse_error_equal.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__parse_error_equal.silt index 1847534f6..ac0c77ad4 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__parse_error_equal.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__parse_error_equal.silt @@ -1,5 +1,5 @@ import int -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } fn main() { println(eq_gen(int.Empty, int.Empty)) println(eq_gen(int.Empty, int.Overflow)) diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__result_equal.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__result_equal.silt index 3143103a3..9786b6d44 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__result_equal.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__result_equal.silt @@ -1,4 +1,4 @@ -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } fn main() { println(eq_gen(Ok(1), Ok(1))) println(eq_gen(Ok(1), Ok(2))) diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__step_compare.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__step_compare.silt index 6995c2e50..1be2c0391 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__step_compare.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__step_compare.silt @@ -1,5 +1,5 @@ import list -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(list.Stop(1), list.Continue(1))) } diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__weekday_compare.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__weekday_compare.silt index b49310fe3..11923923c 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__weekday_compare.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__weekday_compare.silt @@ -1,3 +1,3 @@ import time -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(time.Monday, time.Friday)) } diff --git a/tests/golden/lang/traits/auto_derive_builtin_synth__weekday_compare_three_orderings.silt b/tests/golden/lang/traits/auto_derive_builtin_synth__weekday_compare_three_orderings.silt index af07c5f07..dc2caf72a 100644 --- a/tests/golden/lang/traits/auto_derive_builtin_synth__weekday_compare_three_orderings.silt +++ b/tests/golden/lang/traits/auto_derive_builtin_synth__weekday_compare_three_orderings.silt @@ -1,5 +1,5 @@ import time -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(time.Monday, time.Friday)) println(cmp_gen(time.Friday, time.Monday)) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_basic.silt b/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_basic.silt index 684671f60..2e91b03ee 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_basic.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_basic.silt @@ -1,5 +1,5 @@ type Color { Red, Green, Blue, } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Red, Green)) println(cmp_gen(Green, Red)) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_qualified_matches_bound.silt b/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_qualified_matches_bound.silt index 63f87646c..93cdb64c4 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_qualified_matches_bound.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_qualified_matches_bound.silt @@ -1,6 +1,6 @@ type Color { Red, Green, Blue, } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Red, Green)) - println(Color.compare(Red, Green)) + println(Compare.compare(Red, Green)) } diff --git a/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_with_args.silt b/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_with_args.silt index a707d513e..75f4ac6db 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_with_args.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__compare_enum_with_args.silt @@ -1,5 +1,5 @@ type Tagged { Foo(Int), Bar(Int), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Foo(5), Foo(3))) println(cmp_gen(Foo(3), Foo(5))) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__compare_record.silt b/tests/golden/lang/traits/auto_derive_synth_body__compare_record.silt index c090a0033..19b708157 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__compare_record.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__compare_record.silt @@ -1,5 +1,5 @@ type Point { x: Int, y: Int, } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { let p = Point { x: 1, y: 2 } let q = Point { x: 1, y: 3 } diff --git a/tests/golden/lang/traits/auto_derive_synth_body__decl_order_not_alphabetical.silt b/tests/golden/lang/traits/auto_derive_synth_body__decl_order_not_alphabetical.silt index 54fa840c7..a49454445 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__decl_order_not_alphabetical.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__decl_order_not_alphabetical.silt @@ -1,5 +1,5 @@ type Backwards { Z, Y, A, } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Z, A)) println(cmp_gen(Y, Z)) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__display_enum_nullary.silt b/tests/golden/lang/traits/auto_derive_synth_body__display_enum_nullary.silt index e3c84f590..0eccdd259 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__display_enum_nullary.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__display_enum_nullary.silt @@ -1,5 +1,5 @@ type Color { Red, Green, Blue, } -fn d(a: a) -> String where a: Display { a.display() } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { println(d(Red)) println(d(Green)) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__display_enum_with_args.silt b/tests/golden/lang/traits/auto_derive_synth_body__display_enum_with_args.silt index 695ea95f7..1b2a95294 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__display_enum_with_args.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__display_enum_with_args.silt @@ -1,5 +1,5 @@ type Tagged { Foo(Int), Bar(Int, String), } -fn d(a: a) -> String where a: Display { a.display() } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { println(d(Foo(7))) println(d(Bar(42, "hi"))) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__display_record.silt b/tests/golden/lang/traits/auto_derive_synth_body__display_record.silt index 7766e59cf..c4ccc2381 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__display_record.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__display_record.silt @@ -1,5 +1,5 @@ type Point { x: Int, y: Int, } -fn d(a: a) -> String where a: Display { a.display() } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { let p = Point { x: 1, y: 2 } println(d(p)) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__equal_enum.silt b/tests/golden/lang/traits/auto_derive_synth_body__equal_enum.silt index 2a93a0c9f..62510fd92 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__equal_enum.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__equal_enum.silt @@ -1,5 +1,5 @@ type Color { Red, Green, Blue, } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } fn main() { println(eq_gen(Red, Red)) println(eq_gen(Red, Green)) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__equal_enum_with_args.silt b/tests/golden/lang/traits/auto_derive_synth_body__equal_enum_with_args.silt index 561ef9a21..bbea5cb46 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__equal_enum_with_args.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__equal_enum_with_args.silt @@ -1,5 +1,5 @@ type Pair { Both(Int, Int), Just(Int), } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } fn main() { println(eq_gen(Both(1, 2), Both(1, 2))) println(eq_gen(Both(1, 2), Both(1, 3))) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__equal_record_field_chain.silt b/tests/golden/lang/traits/auto_derive_synth_body__equal_record_field_chain.silt index b65c389ed..43d5d9248 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__equal_record_field_chain.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__equal_record_field_chain.silt @@ -1,5 +1,5 @@ type Point { x: Int, y: Int, } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } fn main() { let p = Point { x: 1, y: 2 } let q = Point { x: 1, y: 2 } diff --git a/tests/golden/lang/traits/auto_derive_synth_body__hash_enum_deterministic.silt b/tests/golden/lang/traits/auto_derive_synth_body__hash_enum_deterministic.silt index 55a072ed4..7b5be5336 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__hash_enum_deterministic.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__hash_enum_deterministic.silt @@ -1,6 +1,6 @@ -- Equal values hash equal; different ordinals hash differently. type Color { Red, Green, Blue, } -fn h(a: a) -> Int where a: Hash { a.hash() } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } fn main() { println(h(Red) == h(Red)) println(h(Red) != h(Green)) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__hash_enum_with_args_deterministic.silt b/tests/golden/lang/traits/auto_derive_synth_body__hash_enum_with_args_deterministic.silt index 5cbdc4b8c..8db1ff8ac 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__hash_enum_with_args_deterministic.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__hash_enum_with_args_deterministic.silt @@ -1,5 +1,5 @@ type Tagged { Foo(Int), Bar(Int), } -fn h(a: a) -> Int where a: Hash { a.hash() } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } fn main() { println(h(Foo(5)) == h(Foo(5))) println(h(Foo(5)) != h(Foo(6))) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__hash_record_combines_fields.silt b/tests/golden/lang/traits/auto_derive_synth_body__hash_record_combines_fields.silt index b51308b46..3702a3483 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__hash_record_combines_fields.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__hash_record_combines_fields.silt @@ -1,6 +1,6 @@ -- Equal records hash equal; permuted fields hash differently. type Point { x: Int, y: Int, } -fn h(a: a) -> Int where a: Hash { a.hash() } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } fn main() { let p = Point { x: 1, y: 2 } let q = Point { x: 1, y: 2 } diff --git a/tests/golden/lang/traits/auto_derive_synth_body__manual_display_overrides.silt b/tests/golden/lang/traits/auto_derive_synth_body__manual_display_overrides.silt index b04cfba7b..0fc0d384a 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__manual_display_overrides.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__manual_display_overrides.silt @@ -2,7 +2,7 @@ type Color { Red, Green, Blue, } trait Display for Color { fn display(self: Color) -> String { "" } } -fn d(a: a) -> String where a: Display { a.display() } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { println(d(Red)) println(d(Blue)) diff --git a/tests/golden/lang/traits/auto_derive_synth_body__qualified_global_present.silt b/tests/golden/lang/traits/auto_derive_synth_body__qualified_global_present.silt index f148c8a14..dd2efec5a 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__qualified_global_present.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__qualified_global_present.silt @@ -1,4 +1,4 @@ type Color { Red, Green, Blue, } fn main() { - println(Color.compare(Red, Green)) + println(Compare.compare(Red, Green)) } diff --git a/tests/golden/lang/traits/auto_derive_synth_body__recursive_enum_compare.silt b/tests/golden/lang/traits/auto_derive_synth_body__recursive_enum_compare.silt index 1c0e50d91..ccd8a95cf 100644 --- a/tests/golden/lang/traits/auto_derive_synth_body__recursive_enum_compare.silt +++ b/tests/golden/lang/traits/auto_derive_synth_body__recursive_enum_compare.silt @@ -1,5 +1,5 @@ type Tree { Leaf, Node(Tree, Tree), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Leaf, Node(Leaf, Leaf))) println(cmp_gen(Node(Leaf, Leaf), Node(Leaf, Leaf))) diff --git a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__channel_direct.silt b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__channel_direct.silt index 0b5c4fbb5..3f01f4743 100644 --- a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__channel_direct.silt +++ b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__channel_direct.silt @@ -3,5 +3,5 @@ trait Pretty { fn pretty(self) -> String } trait Pretty for Channel { fn pretty(self) -> String { "channel" } } fn main() { let ch: Channel(Int) = channel.new(1) - println(ch.pretty()) + println(Pretty.pretty(ch)) } diff --git a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_direct_and_where_bound.silt b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_direct_and_where_bound.silt index f4ebaf226..1e6ea21ed 100644 --- a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_direct_and_where_bound.silt +++ b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_direct_and_where_bound.silt @@ -1,7 +1,7 @@ trait Pretty { fn pretty(self) -> String } trait Pretty for List { fn pretty(self) -> String { "list" } } -fn show(x: a) -> String where a: Pretty { x.pretty() } +fn show(x: a) -> String where a: Pretty { Pretty.pretty(x) } fn main() { - println([1, 2].pretty()) + println(Pretty.pretty([1, 2])) println(show([1, 2])) } diff --git a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_distinct_element_types.silt b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_distinct_element_types.silt index c60640db2..5a0ab8236 100644 --- a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_distinct_element_types.silt +++ b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_distinct_element_types.silt @@ -1,6 +1,6 @@ trait Pretty { fn pretty(self) -> String } trait Pretty for List { fn pretty(self) -> String { "list" } } fn main() { - println([1, 2].pretty()) - println(["a", "b"].pretty()) + println(Pretty.pretty([1, 2])) + println(Pretty.pretty(["a", "b"])) } diff --git a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_impl_range_and_list_receivers.silt b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_impl_range_and_list_receivers.silt index f08e31fcd..700591252 100644 --- a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_impl_range_and_list_receivers.silt +++ b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__list_impl_range_and_list_receivers.silt @@ -1,6 +1,6 @@ trait Pretty { fn pretty(self) -> String } trait Pretty for List { fn pretty(self) -> String { "list" } } fn main() { - println((1..3).pretty()) - println([1, 2].pretty()) + println(Pretty.pretty(1..3)) + println(Pretty.pretty([1, 2])) } diff --git a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__map_direct_and_where_bound.silt b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__map_direct_and_where_bound.silt index 417064583..401a7df47 100644 --- a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__map_direct_and_where_bound.silt +++ b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__map_direct_and_where_bound.silt @@ -1,8 +1,8 @@ trait Pretty { fn pretty(self) -> String } trait Pretty for Map { fn pretty(self) -> String { "map" } } -fn show(x: a) -> String where a: Pretty { x.pretty() } +fn show(x: a) -> String where a: Pretty { Pretty.pretty(x) } fn main() { let m = #{"a": 1} - println(m.pretty()) + println(Pretty.pretty(m)) println(show(m)) } diff --git a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__set_direct_and_where_bound.silt b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__set_direct_and_where_bound.silt index b0bc0adeb..a0493770a 100644 --- a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__set_direct_and_where_bound.silt +++ b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__set_direct_and_where_bound.silt @@ -1,9 +1,9 @@ import set trait Pretty { fn pretty(self) -> String } trait Pretty for Set { fn pretty(self) -> String { "set" } } -fn show(x: a) -> String where a: Pretty { x.pretty() } +fn show(x: a) -> String where a: Pretty { Pretty.pretty(x) } fn main() { let s = set.from_list([1, 2]) - println(s.pretty()) + println(Pretty.pretty(s)) println(show(s)) } diff --git a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__tuple_direct_and_where_bound.silt b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__tuple_direct_and_where_bound.silt index 2e7c503f3..152e59630 100644 --- a/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__tuple_direct_and_where_bound.silt +++ b/tests/golden/lang/traits/bare_builtin_container_impl_target_dispatch__tuple_direct_and_where_bound.silt @@ -1,7 +1,7 @@ trait Pretty { fn pretty(self) -> String } trait Pretty for Tuple { fn pretty(self) -> String { "tuple" } } -fn show(x: a) -> String where a: Pretty { x.pretty() } +fn show(x: a) -> String where a: Pretty { Pretty.pretty(x) } fn main() { - println((1, 2).pretty()) + println(Pretty.pretty((1, 2))) println(show((1, "mixed", true))) } diff --git a/tests/golden/lang/traits/call_method_yield__non_yielding_trait_method.silt b/tests/golden/lang/traits/call_method_yield__non_yielding_trait_method.silt index 99005e288..91a0872bf 100644 --- a/tests/golden/lang/traits/call_method_yield__non_yielding_trait_method.silt +++ b/tests/golden/lang/traits/call_method_yield__non_yielding_trait_method.silt @@ -10,5 +10,5 @@ trait Describe for Counter { fn main() { let c = Counter { n: 42 } - println(c.describe()) + println(Describe.describe(c)) } diff --git a/tests/golden/lang/traits/default_method__calls_other_trait_method_on_self.silt b/tests/golden/lang/traits/default_method__calls_other_trait_method_on_self.silt index cb0f37120..ec2807c7c 100644 --- a/tests/golden/lang/traits/default_method__calls_other_trait_method_on_self.silt +++ b/tests/golden/lang/traits/default_method__calls_other_trait_method_on_self.silt @@ -1,6 +1,6 @@ trait Describable { fn name(self) -> String - fn greet(self) -> String { "hi, {self.name()}" } + fn greet(self) -> String { "hi, {Describable.name(self)}" } } type Person { who: String } @@ -11,5 +11,5 @@ trait Describable for Person { fn main() { let p = Person { who: "alice" } - println(p.greet()) + println(Describable.greet(p)) } diff --git a/tests/golden/lang/traits/default_method__calls_supertrait_method.silt b/tests/golden/lang/traits/default_method__calls_supertrait_method.silt index 86b68ecfb..30eabf874 100644 --- a/tests/golden/lang/traits/default_method__calls_supertrait_method.silt +++ b/tests/golden/lang/traits/default_method__calls_supertrait_method.silt @@ -3,7 +3,7 @@ trait Sup { } trait Sub: Sup { - fn sub_method(self) -> String { "sub-of-{self.sup_method()}" } + fn sub_method(self) -> String { "sub-of-{Sup.sup_method(self)}" } } type Thing { v: Int } @@ -16,5 +16,5 @@ trait Sub for Thing {} fn main() { let t = Thing { v: 1 } - println(t.sub_method()) + println(Sub.sub_method(t)) } diff --git a/tests/golden/lang/traits/default_method__impl_overrides_default.silt b/tests/golden/lang/traits/default_method__impl_overrides_default.silt index 9624157d1..0edc75977 100644 --- a/tests/golden/lang/traits/default_method__impl_overrides_default.silt +++ b/tests/golden/lang/traits/default_method__impl_overrides_default.silt @@ -10,5 +10,5 @@ trait Greeter for Item { fn main() { let it = Item { v: 1 } - println(it.greet()) + println(Greeter.greet(it)) } diff --git a/tests/golden/lang/traits/default_method__mix_default_and_abstract.silt b/tests/golden/lang/traits/default_method__mix_default_and_abstract.silt index 679b5ccc6..21576d279 100644 --- a/tests/golden/lang/traits/default_method__mix_default_and_abstract.silt +++ b/tests/golden/lang/traits/default_method__mix_default_and_abstract.silt @@ -11,6 +11,6 @@ trait Display2 for Item { fn main() { let it = Item { v: 1 } - println(it.show()) - println(it.debug()) + println(Display2.show(it)) + println(Display2.debug(it)) } diff --git a/tests/golden/lang/traits/default_method__parameterized_impl_target.silt b/tests/golden/lang/traits/default_method__parameterized_impl_target.silt index b118e819d..ff55476bb 100644 --- a/tests/golden/lang/traits/default_method__parameterized_impl_target.silt +++ b/tests/golden/lang/traits/default_method__parameterized_impl_target.silt @@ -8,5 +8,5 @@ trait Wrapper for Box(a) {} fn main() { let b = Box { value: 42 } - println(b.describe()) + println(Wrapper.describe(b)) } diff --git a/tests/golden/lang/traits/default_method__used_when_impl_omits.silt b/tests/golden/lang/traits/default_method__used_when_impl_omits.silt index 696a41514..57b01f303 100644 --- a/tests/golden/lang/traits/default_method__used_when_impl_omits.silt +++ b/tests/golden/lang/traits/default_method__used_when_impl_omits.silt @@ -8,5 +8,5 @@ trait Greeter for Item {} fn main() { let it = Item { v: 1 } - println(it.greet()) + println(Greeter.greet(it)) } diff --git a/tests/golden/lang/traits/deferred_record_receiver_method.silt b/tests/golden/lang/traits/deferred_record_receiver_method.silt index ab041a39d..2a1a1abc3 100644 --- a/tests/golden/lang/traits/deferred_record_receiver_method.silt +++ b/tests/golden/lang/traits/deferred_record_receiver_method.silt @@ -7,6 +7,6 @@ trait Greet { fn greet(self) -> String } trait Greet for P { fn greet(self) -> String { "p{self.v}" } } trait Greet for Int { fn greet(self) -> String { "i" } } fn main() { - println(list.map([P { v: 1 }, P { v: 2 }]) { p -> p.greet() }) - println(list.map([1]) { p -> p.greet() }) + println(list.map([P { v: 1 }, P { v: 2 }]) { p -> Greet.greet(p) }) + println(list.map([1]) { p -> Greet.greet(p) }) } diff --git a/tests/golden/lang/traits/derived_impls_call_the_builtin_traits.silt b/tests/golden/lang/traits/derived_impls_call_the_builtin_traits.silt index 252fbc171..1b5d22bf3 100644 --- a/tests/golden/lang/traits/derived_impls_call_the_builtin_traits.silt +++ b/tests/golden/lang/traits/derived_impls_call_the_builtin_traits.silt @@ -4,6 +4,7 @@ -- field's type. import list import map +import string trait Describe { fn display(self) -> String } trait Describe for Int { fn display(self) -> String { "described {self}" } } trait Ranked { fn compare(self, other: Self) -> Int } @@ -14,15 +15,15 @@ trait Hashy { fn hash(self) -> Int } trait Hashy for Int { fn hash(self) -> Int { 7 } } type Pt { x: Int } type Wrap { p: Pt } -fn by_bound(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn by_bound(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { - println(Pt { x: 1 }.display()) + println(string.from(Pt { x: 1 })) println(Pt { x: 1 } < Pt { x: 2 }) println(by_bound(Pt { x: 1 }, Pt { x: 2 })) - println(Wrap { p: Pt { x: 1 } }.compare(Wrap { p: Pt { x: 2 } })) + println(Compare.compare(Wrap { p: Pt { x: 1 } }, Wrap { p: Pt { x: 2 } })) println([Pt { x: 2 }, Pt { x: 1 }] |> list.sort) println(Pt { x: 1 } == Pt { x: 1 }) - println(Pt { x: 1 }.equal(Pt { x: 1 })) - println(Pt { x: 1 }.hash() == Pt { x: 2 }.hash()) + println(Pt { x: 1 } == Pt { x: 1 }) + println(Hash.hash(Pt { x: 1 }) == Hash.hash(Pt { x: 2 })) println(map.get(#{ Pt { x: 1 }: "a" }, Pt { x: 1 })) } diff --git a/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/a.silt b/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/a.silt index 89dd9031b..6494a4ddd 100644 --- a/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/a.silt +++ b/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/a.silt @@ -1,4 +1,4 @@ pub trait Describe { fn display(self) -> String } trait Describe for Int { fn display(self) -> String { "A{self}" } } -fn show(x: t) -> String where t: Describe { x.display() } +fn show(x: t) -> String where t: Describe { Describe.display(x) } pub fn f() -> String { show(1) } diff --git a/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/b.silt b/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/b.silt index dd0b00a72..af37b9377 100644 --- a/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/b.silt +++ b/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/b.silt @@ -1,4 +1,4 @@ pub trait Describe { fn display(self) -> String } trait Describe for Int { fn display(self) -> String { "B{self}" } } -fn show(x: t) -> String where t: Describe { x.display() } +fn show(x: t) -> String where t: Describe { Describe.display(x) } pub fn f() -> String { show(1) } diff --git a/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/main.silt b/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/main.silt index bda8be929..4e563e046 100644 --- a/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/main.silt +++ b/tests/golden/lang/traits/derived_impls_ignore_another_modules_trait/main.silt @@ -3,11 +3,12 @@ -- and each module's call through its own bound calls its impl. import a import helper +import string type Pt { x: Int } fn main() { println(a.f()) println(helper.g()) - println(Pt { x: 1 }.display()) + println(string.from(Pt { x: 1 })) println(Pt { x: 1 } == Pt { x: 1 }) println("{Pt { x: 2 }}") } diff --git a/tests/golden/lang/traits/dispatch_unit_validation__trait_args_checked_when_inner_is_unit.silt b/tests/golden/lang/traits/dispatch_unit_validation__trait_args_checked_when_inner_is_unit.silt index 9d8938cdf..424f0ecb2 100644 --- a/tests/golden/lang/traits/dispatch_unit_validation__trait_args_checked_when_inner_is_unit.silt +++ b/tests/golden/lang/traits/dispatch_unit_validation__trait_args_checked_when_inner_is_unit.silt @@ -17,6 +17,6 @@ trait Foo for Box(a) where a: T(Int) { } fn main() { let b: Box(Unit) = Wrap(()) - let r: Int = b.do_it() + let r: Int = Foo.do_it(b) println(r) } diff --git a/tests/golden/lang/traits/display__a_written_impl_is_what_every_way_of_showing_prints.silt b/tests/golden/lang/traits/display__a_written_impl_is_what_every_way_of_showing_prints.silt index 2d5f97c7f..e16f303d1 100644 --- a/tests/golden/lang/traits/display__a_written_impl_is_what_every_way_of_showing_prints.silt +++ b/tests/golden/lang/traits/display__a_written_impl_is_what_every_way_of_showing_prints.silt @@ -17,21 +17,21 @@ trait Display for Temp { trait Error for Temp {} fn show(x: a) -> String where a: Display { - x.display() + "{x}" } fn main() { let t = Temp { degrees: 21 } - println(t.display()) + println("{t}") println("{t}") println(t) println(string.from(t)) println(show(t)) - println(t.message()) + println(Error.message(t)) print(t) println("") println([t]) println("{[t]}") - println([t].display()) + println("{[t]}") println(show([t])) } diff --git a/tests/golden/lang/traits/display__an_impl_shows_its_fields_with_their_impls.silt b/tests/golden/lang/traits/display__an_impl_shows_its_fields_with_their_impls.silt index a8e2b24e7..c314b0dbf 100644 --- a/tests/golden/lang/traits/display__an_impl_shows_its_fields_with_their_impls.silt +++ b/tests/golden/lang/traits/display__an_impl_shows_its_fields_with_their_impls.silt @@ -20,7 +20,7 @@ type Span { trait Display for Span { fn display(self) -> String { - "{self.low}..{self.high.display()}" + "{self.low}..{self.high}" } } @@ -35,7 +35,7 @@ trait Display for Forecast { } fn both(x: a, y: b) -> String where a: Display, b: Display { - "<{x}> <{y.display()}>" + "<{x}> <{y}>" } fn main() { diff --git a/tests/golden/lang/traits/dot_after_a_value__a_method_of_a_builtin_trait_or_that_makes_a_value.silt b/tests/golden/lang/traits/dot_after_a_value__a_method_of_a_builtin_trait_or_that_makes_a_value.silt new file mode 100644 index 000000000..59758a876 --- /dev/null +++ b/tests/golden/lang/traits/dot_after_a_value__a_method_of_a_builtin_trait_or_that_makes_a_value.silt @@ -0,0 +1,15 @@ +-- cmd: check +-- exit: 1 +-- `display` and `equal` are no methods a program calls: the help shows +-- interpolation, `string.from` and `==`. A method that makes a value is +-- called on the type, or on a `type a` parameter. +trait Monoid { fn empty() -> Self } +trait Monoid for Int { fn empty() -> Self { 0 } } +fn of(x: a) -> a where a: Monoid { x.empty() } +fn main() { + let n = 5 + println(n.display()) + println(n.equal(n)) + println(n.empty()) + println(of(1)) +} diff --git a/tests/golden/lang/traits/dot_after_a_value__a_method_of_a_builtin_trait_or_that_makes_a_value.stderr b/tests/golden/lang/traits/dot_after_a_value__a_method_of_a_builtin_trait_or_that_makes_a_value.stderr new file mode 100644 index 000000000..bbbab5681 --- /dev/null +++ b/tests/golden/lang/traits/dot_after_a_value__a_method_of_a_builtin_trait_or_that_makes_a_value.stderr @@ -0,0 +1,27 @@ +error[type]: type 'a' has no field 'empty' + --> dot_after_a_value__a_method_of_a_builtin_trait_or_that_makes_a_value.silt:8:36 + | + 8 | fn of(x: a) -> a where a: Monoid { x.empty() } + | ^^^^^^^ type 'a' has no field 'empty' + = help: `empty` is a method of trait `Monoid` that makes a value: call it on the type, `a.empty()`, where `a` is a `type a` parameter + +error[type]: type 'Int' has no field 'display' + --> dot_after_a_value__a_method_of_a_builtin_trait_or_that_makes_a_value.silt:11:11 + | + 11 | println(n.display()) + | ^^^^^^^^^ type 'Int' has no field 'display' + = help: show a value with interpolation, `"{n}"`, or with `string.from(n)` + +error[type]: type 'Int' has no field 'equal' + --> dot_after_a_value__a_method_of_a_builtin_trait_or_that_makes_a_value.silt:12:11 + | + 12 | println(n.equal(n)) + | ^^^^^^^ type 'Int' has no field 'equal' + = help: compare with `==`: `n == y` + +error[type]: type 'Int' has no field 'empty' + --> dot_after_a_value__a_method_of_a_builtin_trait_or_that_makes_a_value.silt:13:11 + | + 13 | println(n.empty()) + | ^^^^^^^ type 'Int' has no field 'empty' + = help: `empty` is a method of trait `Monoid` that makes a value: call it on the type, `Int.empty()` diff --git a/tests/golden/lang/traits/dot_after_a_value__names_a_field.silt b/tests/golden/lang/traits/dot_after_a_value__names_a_field.silt new file mode 100644 index 000000000..48b31e7da --- /dev/null +++ b/tests/golden/lang/traits/dot_after_a_value__names_a_field.silt @@ -0,0 +1,28 @@ +-- cmd: check +-- exit: 1 +-- A dot after a value names a field. Where the value's type has none of +-- the name, the error says so; the help names the trait in sight that +-- has a method of the name and the call to write, with the receiver as +-- written when it is a name (`Greet.greet(n)`) and `x` otherwise; or +-- the builtin module of the type with a function of the name. Also +-- through a function whose parameter's type is unknown, which takes a +-- record with the field. +import list +trait Greet { fn greet(self) -> String } +trait Greet for Int { fn greet(self) -> String { "g" } } +trait Pair { fn pair(self, other: Self) -> String } +trait Pair for Int { fn pair(self, other: Self) -> String { "p" } } +fn h(x) { x.frobnicate() } +fn main() { + let n = 5 + println(n.frobnicate()) + println(n.greet()) + println((n + 1).greet()) + println(n.pair(6)) + let xs = [1, 2] + println(xs.length()) + println([1].length()) + println("s".length()) + println(h(1)) + let g = n.greet +} diff --git a/tests/golden/lang/traits/dot_after_a_value__names_a_field.stderr b/tests/golden/lang/traits/dot_after_a_value__names_a_field.stderr new file mode 100644 index 000000000..b67609788 --- /dev/null +++ b/tests/golden/lang/traits/dot_after_a_value__names_a_field.stderr @@ -0,0 +1,60 @@ +error[type]: type 'Int' has no field 'frobnicate' + --> dot_after_a_value__names_a_field.silt:18:11 + | + 18 | println(n.frobnicate()) + | ^^^^^^^^^^^^ type 'Int' has no field 'frobnicate' + +error[type]: type 'Int' has no field 'greet' + --> dot_after_a_value__names_a_field.silt:19:11 + | + 19 | println(n.greet()) + | ^^^^^^^ type 'Int' has no field 'greet' + = help: `greet` is a method of trait `Greet`: call it as `Greet.greet(n)` + +error[type]: type 'Int' has no field 'greet' + --> dot_after_a_value__names_a_field.silt:20:12 + | + 20 | println((n + 1).greet()) + | ^^^^^^^^^^^^ type 'Int' has no field 'greet' + = help: `greet` is a method of trait `Greet`: call it as `Greet.greet(x)` + +error[type]: type 'Int' has no field 'pair' + --> dot_after_a_value__names_a_field.silt:21:11 + | + 21 | println(n.pair(6)) + | ^^^^^^ type 'Int' has no field 'pair' + = help: `pair` is a method of trait `Pair`: call it as `Pair.pair(n, ..)` + +error[type]: type 'List(Int)' has no field 'length' + --> dot_after_a_value__names_a_field.silt:23:11 + | + 23 | println(xs.length()) + | ^^^^^^^^^ type 'List(Int)' has no field 'length' + = help: `length` is a function of module `list`: call it as `list.length(xs)` + +error[type]: type 'List(Int)' has no field 'length' + --> dot_after_a_value__names_a_field.silt:24:11 + | + 24 | println([1].length()) + | ^^^^^^^^^^ type 'List(Int)' has no field 'length' + = help: `length` is a function of module `list`: call it as `list.length(xs)` + +error[type]: type 'String' has no field 'length' + --> dot_after_a_value__names_a_field.silt:25:11 + | + 25 | println("s".length()) + | ^^^^^^^^^^ type 'String' has no field 'length' + = help: `length` is a function of module `string`: call it as `string.length(x)` + +error[type]: type 'Int' has no field 'frobnicate' + --> dot_after_a_value__names_a_field.silt:26:13 + | + 26 | println(h(1)) + | ^ type 'Int' has no field 'frobnicate' + +error[type]: type 'Int' has no field 'greet' + --> dot_after_a_value__names_a_field.silt:27:11 + | + 27 | let g = n.greet + | ^^^^^^^ type 'Int' has no field 'greet' + = help: `greet` is a method of trait `Greet`: call it as `Greet.greet(n)` diff --git a/tests/golden/lang/traits/every_fn_and_tuple__associated_type_and_trait_parameter.silt b/tests/golden/lang/traits/every_fn_and_tuple__associated_type_and_trait_parameter.silt index bd5010580..a80821cff 100644 --- a/tests/golden/lang/traits/every_fn_and_tuple__associated_type_and_trait_parameter.silt +++ b/tests/golden/lang/traits/every_fn_and_tuple__associated_type_and_trait_parameter.silt @@ -7,9 +7,9 @@ trait Has { type Item fn item(self) -> Self::Item } trait Has for Tuple { type Item = Int fn item(self) -> Int { 2 } } -fn c(x: a, type b) -> b where a: Conv(b) { x.conv() } +fn c(x: a, type b) -> b where a: Conv(b) { Conv.conv(x) } fn main() { - println({ x -> x }.conv()) + println(Conv.conv({ x -> x })) println(c({ x -> x + 1 }, Int)) - println((1, 2).item()) + println(Has.item((1, 2))) } diff --git a/tests/golden/lang/traits/every_fn_and_tuple__what_self_can_do.silt b/tests/golden/lang/traits/every_fn_and_tuple__what_self_can_do.silt index 867a01136..94296f6fc 100644 --- a/tests/golden/lang/traits/every_fn_and_tuple__what_self_can_do.silt +++ b/tests/golden/lang/traits/every_fn_and_tuple__what_self_can_do.silt @@ -7,36 +7,36 @@ trait Keep { fn name(self) -> String fn both(self) -> String fn pick(self, o: Self) -> Self - fn twice(self) -> String { "{self.name()} {self.name()}" } + fn twice(self) -> String { "{Keep.name(self)} {Keep.name(self)}" } } trait Keep for Fn { fn keep(self) -> Self { self } fn name(self) -> String { "fn" } - fn both(self) -> String { "{self.name()}+{self.keep().name()}" } + fn both(self) -> String { "{Keep.name(self)}+{Keep.name(Keep.keep(self))}" } fn pick(self, o: Self) -> Self { o } } trait Keep for Tuple { fn keep(self) -> Self { self } fn name(self) -> String { "tuple" } - fn both(self) -> String { self.name() } + fn both(self) -> String { Keep.name(self) } fn pick(self, o: Self) -> Self { o } } fn cents(n: Int) -> Cents { Cents(n) } fn other(n: Int) -> Cents { Cents(n + 1) } -fn k(x: a) -> a where a: Keep { x.keep() } +fn k(x: a) -> a where a: Keep { Keep.keep(x) } fn main() { - let f = cents.keep() + let f = Keep.keep(cents) let Cents(n) = f(3) println(n) - println(cents.both()) - println(cents.twice()) - let g = cents.pick(other) + println(Keep.both(cents)) + println(Keep.twice(cents)) + let g = Keep.pick(cents, other) println(g(1)) - let (a, b) = (1, "x").keep() + let (a, b) = Keep.keep((1, "x")) println("{a} {b}") - println((1, 2).pick((3, 4))) + println(Keep.pick((1, 2), (3, 4))) let h = k(cents) println(h(9)) println(k((1, 2))) - println({ x -> x + 1 }.name()) + println(Keep.name({ x -> x + 1 })) } diff --git a/tests/golden/lang/traits/imported_type_with_two_written_displays/main.silt b/tests/golden/lang/traits/imported_type_with_two_written_displays/main.silt index 4a0bcfe96..fceb82e02 100644 --- a/tests/golden/lang/traits/imported_type_with_two_written_displays/main.silt +++ b/tests/golden/lang/traits/imported_type_with_two_written_displays/main.silt @@ -3,6 +3,7 @@ -- stderr-contains: error[type]: duplicate implementation of trait 'Display' for type 'types.Tag' -- A second written Display impl for an imported type is a duplicate. import types.{ Tag } +import string trait Display for Tag { fn display(self) -> String { @@ -11,5 +12,5 @@ trait Display for Tag { } fn main() { - println(Tag { name: "silt" }.display()) + println(string.from(Tag { name: "silt" })) } diff --git a/tests/golden/lang/traits/imported_type_with_written_display/main.silt b/tests/golden/lang/traits/imported_type_with_written_display/main.silt index 4a2cbfede..8fd5294f0 100644 --- a/tests/golden/lang/traits/imported_type_with_written_display/main.silt +++ b/tests/golden/lang/traits/imported_type_with_written_display/main.silt @@ -7,6 +7,6 @@ import types.{ Tag } fn main() { let t = Tag { name: "silt" } - println(t.display()) - println("{t.display()}") + println("{t}") + println("{t}") } diff --git a/tests/golden/lang/traits/imported_type_with_written_display_check/main.silt b/tests/golden/lang/traits/imported_type_with_written_display_check/main.silt index 3243fa393..b42a8a34a 100644 --- a/tests/golden/lang/traits/imported_type_with_written_display_check/main.silt +++ b/tests/golden/lang/traits/imported_type_with_written_display_check/main.silt @@ -8,6 +8,6 @@ import types.{ Tag } fn main() { let t = Tag { name: "silt" } - println(t.display()) - println("{t.display()}") + println("{t}") + println("{t}") } diff --git a/tests/golden/lang/traits/private_trait_is_no_candidate_beside_own/helper.silt b/tests/golden/lang/traits/private_trait_is_no_candidate_beside_own/helper.silt index bd4fb9f15..aeff4ff0b 100644 --- a/tests/golden/lang/traits/private_trait_is_no_candidate_beside_own/helper.silt +++ b/tests/golden/lang/traits/private_trait_is_no_candidate_beside_own/helper.silt @@ -1,3 +1,3 @@ trait Show { fn show(self) -> String } trait Show for Int { fn show(self) -> String { "helper {self}" } } -pub fn h() -> String { 1.show() } +pub fn h() -> String { Show.show(1) } diff --git a/tests/golden/lang/traits/private_trait_is_no_candidate_beside_own/main.silt b/tests/golden/lang/traits/private_trait_is_no_candidate_beside_own/main.silt index fb33e294e..437b0688d 100644 --- a/tests/golden/lang/traits/private_trait_is_no_candidate_beside_own/main.silt +++ b/tests/golden/lang/traits/private_trait_is_no_candidate_beside_own/main.silt @@ -7,8 +7,8 @@ trait Show for Int { fn show(self) -> String { "main {self}" } } fn apply(f: Fn(a) -> String, x: a) -> String { f(x) } fn main() { println(helper.h()) - println(2.show()) - let g = { y -> y.show() } + println(Show.show(2)) + let g = { y -> Show.show(y) } println(g(3)) - println(apply({ y -> y.show() }, 4)) + println(apply({ y -> Show.show(y) }, 4)) } diff --git a/tests/golden/lang/traits/private_trait_is_no_candidate_beside_pub/b.silt b/tests/golden/lang/traits/private_trait_is_no_candidate_beside_pub/b.silt index c8fb61396..9aa794484 100644 --- a/tests/golden/lang/traits/private_trait_is_no_candidate_beside_pub/b.silt +++ b/tests/golden/lang/traits/private_trait_is_no_candidate_beside_pub/b.silt @@ -1,3 +1,3 @@ trait Show { fn show(self) -> String } trait Show for Int { fn show(self) -> String { "b-int {self}" } } -pub fn sb(x: Int) -> String { x.show() } +pub fn sb(x: Int) -> String { Show.show(x) } diff --git a/tests/golden/lang/traits/private_trait_is_no_candidate_beside_pub/main.silt b/tests/golden/lang/traits/private_trait_is_no_candidate_beside_pub/main.silt index 66b6d623b..49263d5ed 100644 --- a/tests/golden/lang/traits/private_trait_is_no_candidate_beside_pub/main.silt +++ b/tests/golden/lang/traits/private_trait_is_no_candidate_beside_pub/main.silt @@ -4,6 +4,6 @@ import a import b fn main() { println(b.sb(1)) - println(2.show()) - println(Int.show(3)) + println(a.Show.show(2)) + println(a.Show.show(3)) } diff --git a/tests/golden/lang/traits/round71_direct_dispatch__channel_user_trait_dispatch.silt b/tests/golden/lang/traits/round71_direct_dispatch__channel_user_trait_dispatch.silt index a77a09d7a..91b11dee9 100644 --- a/tests/golden/lang/traits/round71_direct_dispatch__channel_user_trait_dispatch.silt +++ b/tests/golden/lang/traits/round71_direct_dispatch__channel_user_trait_dispatch.silt @@ -3,5 +3,5 @@ trait Show { fn show(self) -> String } trait Show for Channel(a) { fn show(self) -> String { "chan-impl" } } fn main() { let c: Channel(Int) = channel.new(1) - println(c.show()) + println(Show.show(c)) } diff --git a/tests/golden/lang/traits/round71_direct_dispatch__fn_user_trait_dispatch.silt b/tests/golden/lang/traits/round71_direct_dispatch__fn_user_trait_dispatch.silt index 390aa1da2..c69abddd4 100644 --- a/tests/golden/lang/traits/round71_direct_dispatch__fn_user_trait_dispatch.silt +++ b/tests/golden/lang/traits/round71_direct_dispatch__fn_user_trait_dispatch.silt @@ -2,5 +2,5 @@ trait Show { fn show(self) -> String } trait Show for Fn { fn show(self) -> String { "fn-impl" } } fn main() { let f = { -> 42 } - println(f.show()) + println(Show.show(f)) } diff --git a/tests/golden/lang/traits/round71_followup_fn_canonical_name__user_trait_for_fn_dispatches.silt b/tests/golden/lang/traits/round71_followup_fn_canonical_name__user_trait_for_fn_dispatches.silt index 390aa1da2..c69abddd4 100644 --- a/tests/golden/lang/traits/round71_followup_fn_canonical_name__user_trait_for_fn_dispatches.silt +++ b/tests/golden/lang/traits/round71_followup_fn_canonical_name__user_trait_for_fn_dispatches.silt @@ -2,5 +2,5 @@ trait Show { fn show(self) -> String } trait Show for Fn { fn show(self) -> String { "fn-impl" } } fn main() { let f = { -> 42 } - println(f.show()) + println(Show.show(f)) } diff --git a/tests/golden/lang/traits/round71_followup_fn_canonical_name__user_trait_for_fun_alias_dispatches.silt b/tests/golden/lang/traits/round71_followup_fn_canonical_name__user_trait_for_fun_alias_dispatches.silt index 71c4c6ee0..0fd5c4118 100644 --- a/tests/golden/lang/traits/round71_followup_fn_canonical_name__user_trait_for_fun_alias_dispatches.silt +++ b/tests/golden/lang/traits/round71_followup_fn_canonical_name__user_trait_for_fun_alias_dispatches.silt @@ -2,5 +2,5 @@ trait Show { fn show(self) -> String } trait Show for Fun { fn show(self) -> String { "fn-impl" } } fn main() { let f = { -> 42 } - println(f.show()) + println(Show.show(f)) } diff --git a/tests/golden/lang/traits/round76_assoc_cycle__direct_self_reference_rejected.silt b/tests/golden/lang/traits/round76_assoc_cycle__direct_self_reference_rejected.silt index 71e20faff..320377d8d 100644 --- a/tests/golden/lang/traits/round76_assoc_cycle__direct_self_reference_rejected.silt +++ b/tests/golden/lang/traits/round76_assoc_cycle__direct_self_reference_rejected.silt @@ -15,5 +15,5 @@ trait Container for Int { fn main() { let x: Int = 7 - println(x.unwrap()) + println(Container.unwrap(x)) } diff --git a/tests/golden/lang/traits/round77_for_fn_builtinfn_dispatch__builtin_fn_value.silt b/tests/golden/lang/traits/round77_for_fn_builtinfn_dispatch__builtin_fn_value.silt index a72c8ab87..5d435c987 100644 --- a/tests/golden/lang/traits/round77_for_fn_builtinfn_dispatch__builtin_fn_value.silt +++ b/tests/golden/lang/traits/round77_for_fn_builtinfn_dispatch__builtin_fn_value.silt @@ -2,5 +2,5 @@ trait MyTrait { fn describe(self) -> String } trait MyTrait for Fn { fn describe(self) -> String { "[fn]" } } fn main() { let h = println - println(h.describe()) + println(MyTrait.describe(h)) } diff --git a/tests/golden/lang/traits/round77_for_fn_builtinfn_dispatch__variant_constructor_value.silt b/tests/golden/lang/traits/round77_for_fn_builtinfn_dispatch__variant_constructor_value.silt index 61f369c3d..7d2a0bb84 100644 --- a/tests/golden/lang/traits/round77_for_fn_builtinfn_dispatch__variant_constructor_value.silt +++ b/tests/golden/lang/traits/round77_for_fn_builtinfn_dispatch__variant_constructor_value.silt @@ -3,5 +3,5 @@ trait MyTrait for Fn { fn describe(self) -> String { "[fn]" } } type Maybe(a) { May(a) } fn main() { let h = May - println(h.describe()) + println(MyTrait.describe(h)) } diff --git a/tests/golden/lang/traits/round88_unit_variant_method_dispatch__bare_unit_variant.silt b/tests/golden/lang/traits/round88_unit_variant_method_dispatch__bare_unit_variant.silt index 9f7f2cb57..1368fd380 100644 --- a/tests/golden/lang/traits/round88_unit_variant_method_dispatch__bare_unit_variant.silt +++ b/tests/golden/lang/traits/round88_unit_variant_method_dispatch__bare_unit_variant.silt @@ -6,5 +6,5 @@ trait Display for Color { } fn main() { - println(Red.display()) + println("{Red}") } diff --git a/tests/golden/lang/traits/round88_unit_variant_method_dispatch__let_bound_unit_variant.silt b/tests/golden/lang/traits/round88_unit_variant_method_dispatch__let_bound_unit_variant.silt index a2f87fb5a..d6d18319f 100644 --- a/tests/golden/lang/traits/round88_unit_variant_method_dispatch__let_bound_unit_variant.silt +++ b/tests/golden/lang/traits/round88_unit_variant_method_dispatch__let_bound_unit_variant.silt @@ -6,5 +6,5 @@ trait Display for Color { fn main() { let r = Red - println(r.display()) + println("{r}") } diff --git a/tests/golden/lang/traits/round88_unit_variant_method_dispatch__paren_unit_variant.silt b/tests/golden/lang/traits/round88_unit_variant_method_dispatch__paren_unit_variant.silt index 9d74f05f3..1368fd380 100644 --- a/tests/golden/lang/traits/round88_unit_variant_method_dispatch__paren_unit_variant.silt +++ b/tests/golden/lang/traits/round88_unit_variant_method_dispatch__paren_unit_variant.silt @@ -6,5 +6,5 @@ trait Display for Color { } fn main() { - println((Red).display()) + println("{Red}") } diff --git a/tests/golden/lang/traits/round88_unit_variant_method_dispatch__returns_value_from_trait_body.silt b/tests/golden/lang/traits/round88_unit_variant_method_dispatch__returns_value_from_trait_body.silt index 08535a8e7..678ecaf7a 100644 --- a/tests/golden/lang/traits/round88_unit_variant_method_dispatch__returns_value_from_trait_body.silt +++ b/tests/golden/lang/traits/round88_unit_variant_method_dispatch__returns_value_from_trait_body.silt @@ -5,4 +5,4 @@ trait Display for Color { fn display(self) -> String { "round88-ok" } } -fn main() { println(Red.display()) } +fn main() { println("{Red}") } diff --git a/tests/golden/lang/traits/round93_autoderive_field_gate__derivable_enum_with_payload_runs.silt b/tests/golden/lang/traits/round93_autoderive_field_gate__derivable_enum_with_payload_runs.silt index 16d12fa6a..595b78364 100644 --- a/tests/golden/lang/traits/round93_autoderive_field_gate__derivable_enum_with_payload_runs.silt +++ b/tests/golden/lang/traits/round93_autoderive_field_gate__derivable_enum_with_payload_runs.silt @@ -2,6 +2,6 @@ type Shape { Dot, Line(Int), Rect(Int, Int) } fn main() { println(Dot < Line(1)) println(Line(1) == Line(1)) - println(Line(1).compare(Rect(1, 2))) - println(Rect(1, 2).hash() == Rect(1, 2).hash()) + println(Compare.compare(Line(1), Rect(1, 2))) + println(Hash.hash(Rect(1, 2)) == Hash.hash(Rect(1, 2))) } diff --git a/tests/golden/lang/traits/round93_autoderive_field_gate__derivable_record_runs.silt b/tests/golden/lang/traits/round93_autoderive_field_gate__derivable_record_runs.silt index 00d6e674e..376bc8448 100644 --- a/tests/golden/lang/traits/round93_autoderive_field_gate__derivable_record_runs.silt +++ b/tests/golden/lang/traits/round93_autoderive_field_gate__derivable_record_runs.silt @@ -4,6 +4,6 @@ fn main() { let b = P{x: 2, name: "b"} println(a < b) println(a == b) - println(a.compare(b)) - println(a.hash() == a.hash()) + println(Compare.compare(a, b)) + println(Hash.hash(a) == Hash.hash(a)) } diff --git a/tests/golden/lang/traits/round93_autoderive_field_gate__enum_wrapping_map_compare_method_rejected.silt b/tests/golden/lang/traits/round93_autoderive_field_gate__enum_wrapping_map_compare_method_rejected.silt index e019e85ac..697374948 100644 --- a/tests/golden/lang/traits/round93_autoderive_field_gate__enum_wrapping_map_compare_method_rejected.silt +++ b/tests/golden/lang/traits/round93_autoderive_field_gate__enum_wrapping_map_compare_method_rejected.silt @@ -4,4 +4,4 @@ -- stderr-contains: variant 'Wrap' type W { Wrap(Map(String, Int)), Empty } fn mk() -> W { Wrap(#{"a": 1}) } -fn main() { println(mk().compare(mk())) } +fn main() { println(Compare.compare(mk(), mk())) } diff --git a/tests/golden/lang/traits/round93_autoderive_field_gate__fn_field_compare_method_rejected.silt b/tests/golden/lang/traits/round93_autoderive_field_gate__fn_field_compare_method_rejected.silt index a0e02dde1..bc7022afb 100644 --- a/tests/golden/lang/traits/round93_autoderive_field_gate__fn_field_compare_method_rejected.silt +++ b/tests/golden/lang/traits/round93_autoderive_field_gate__fn_field_compare_method_rejected.silt @@ -5,4 +5,4 @@ -- stderr-contains: Fn(Int) -> Int type H { f: Fn(Int) -> Int } fn mk() -> H { H{f: { x -> x }} } -fn main() { println(mk().compare(mk())) } +fn main() { println(Compare.compare(mk(), mk())) } diff --git a/tests/golden/lang/traits/round93_autoderive_field_gate__fn_field_hash_method_rejected.silt b/tests/golden/lang/traits/round93_autoderive_field_gate__fn_field_hash_method_rejected.silt index d0cbb6201..a32e57c26 100644 --- a/tests/golden/lang/traits/round93_autoderive_field_gate__fn_field_hash_method_rejected.silt +++ b/tests/golden/lang/traits/round93_autoderive_field_gate__fn_field_hash_method_rejected.silt @@ -5,4 +5,4 @@ -- stderr-contains: Fn(Int) -> Int type H { f: Fn(Int) -> Int } fn mk() -> H { H{f: { x -> x }} } -fn main() { println(mk().hash()) } +fn main() { println(Hash.hash(mk())) } diff --git a/tests/golden/lang/traits/round93_autoderive_field_gate__generic_record_int_instantiation_runs.silt b/tests/golden/lang/traits/round93_autoderive_field_gate__generic_record_int_instantiation_runs.silt index 333b0ae79..0d9893c08 100644 --- a/tests/golden/lang/traits/round93_autoderive_field_gate__generic_record_int_instantiation_runs.silt +++ b/tests/golden/lang/traits/round93_autoderive_field_gate__generic_record_int_instantiation_runs.silt @@ -4,6 +4,6 @@ fn main() { let b = Box{v: 2} println(a < b) println(a == b) - println(a.compare(b)) - println(a.hash() == a.hash()) + println(Compare.compare(a, b)) + println(Hash.hash(a) == Hash.hash(a)) } diff --git a/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_compare_method_rejected.silt b/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_compare_method_rejected.silt index 8147ce8f1..6efa8579f 100644 --- a/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_compare_method_rejected.silt +++ b/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_compare_method_rejected.silt @@ -5,4 +5,4 @@ -- stderr-contains: Map(String, Int) type M { m: Map(String, Int) } fn mk() -> M { M{m: #{"a": 1}} } -fn main() { println(mk().compare(mk())) } +fn main() { println(Compare.compare(mk(), mk())) } diff --git a/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_equality_and_hash_run.silt b/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_equality_and_hash_run.silt index b37e05ddf..624aae358 100644 --- a/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_equality_and_hash_run.silt +++ b/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_equality_and_hash_run.silt @@ -5,5 +5,5 @@ fn main() { let c = M{m: #{"a": 2}} println(a == b) println(a == c) - println(a.hash() == b.hash()) + println(Hash.hash(a) == Hash.hash(b)) } diff --git a/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_where_clause_rejected.silt b/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_where_clause_rejected.silt index a7ab18bfc..062d951b2 100644 --- a/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_where_clause_rejected.silt +++ b/tests/golden/lang/traits/round93_autoderive_field_gate__map_field_where_clause_rejected.silt @@ -3,5 +3,5 @@ -- stderr-contains: error[type]: type 'M' does not implement trait 'Compare': field 'm' is of type 'Map(String, Int)', which does not type M { m: Map(String, Int) } fn mk() -> M { M{m: #{"a": 1}} } -fn cmp_gen(x: a, y: a) -> Int where a: Compare { x.compare(y) } +fn cmp_gen(x: a, y: a) -> Int where a: Compare { Compare.compare(x, y) } fn main() { println(cmp_gen(mk(), mk())) } diff --git a/tests/golden/lang/traits/round93_autoderive_field_gate__recursive_type_derives_and_runs.silt b/tests/golden/lang/traits/round93_autoderive_field_gate__recursive_type_derives_and_runs.silt index b46bc446a..5cc935dd1 100644 --- a/tests/golden/lang/traits/round93_autoderive_field_gate__recursive_type_derives_and_runs.silt +++ b/tests/golden/lang/traits/round93_autoderive_field_gate__recursive_type_derives_and_runs.silt @@ -4,6 +4,6 @@ fn main() { let t2 = Tree{leaf: 2, kids: [Tree{leaf: 3, kids: []}]} println(t1 < t2) println(t1 == t1) - println(t1.compare(t2)) - println(t2.hash() == t2.hash()) + println(Compare.compare(t1, t2)) + println(Hash.hash(t2) == Hash.hash(t2)) } diff --git a/tests/golden/lang/traits/same_named_traits_ambiguous_call/a.silt b/tests/golden/lang/traits/same_named_traits_ambiguous_call/a.silt deleted file mode 100644 index 664e1cbdb..000000000 --- a/tests/golden/lang/traits/same_named_traits_ambiguous_call/a.silt +++ /dev/null @@ -1,4 +0,0 @@ -pub trait Show { fn show(self) -> String } -trait Show for Int { fn show(self) -> String { "a-int {self}" } } -pub fn show_int(x: Int) -> String { x.show() } -pub fn use_show(x: t) -> String where t: Show { x.show() } diff --git a/tests/golden/lang/traits/same_named_traits_ambiguous_call/b.silt b/tests/golden/lang/traits/same_named_traits_ambiguous_call/b.silt deleted file mode 100644 index fb3808b31..000000000 --- a/tests/golden/lang/traits/same_named_traits_ambiguous_call/b.silt +++ /dev/null @@ -1,4 +0,0 @@ -pub trait Show { fn show(self) -> String } -trait Show for Int { fn show(self) -> String { "b-int {self}" } } -pub fn show_int(x: Int) -> String { x.show() } -pub fn use_show(x: t) -> String where t: Show { x.show() } diff --git a/tests/golden/lang/traits/same_named_traits_ambiguous_call/main.silt b/tests/golden/lang/traits/same_named_traits_ambiguous_call/main.silt deleted file mode 100644 index 47d974b8a..000000000 --- a/tests/golden/lang/traits/same_named_traits_ambiguous_call/main.silt +++ /dev/null @@ -1,13 +0,0 @@ --- exit: 1 --- Two modules each declare a trait `Show` with `fn show` and implement --- it for Int. A call here, which sees both traits, is ambiguous: an --- error at the call, naming both traits. --- stderr-contains: error[type]: ambiguous method 'show' on type 'Int': provided by traits a.Show, b.Show --- stderr-contains: --> main.silt:11:11 --- stderr-contains: --> main.silt:12:11 -import a -import b -fn main() { - println(5.show()) - println(Int.show(6)) -} diff --git a/tests/golden/lang/traits/same_named_traits_deferred_ambiguous/a.silt b/tests/golden/lang/traits/same_named_traits_deferred_ambiguous/a.silt deleted file mode 100644 index 664e1cbdb..000000000 --- a/tests/golden/lang/traits/same_named_traits_deferred_ambiguous/a.silt +++ /dev/null @@ -1,4 +0,0 @@ -pub trait Show { fn show(self) -> String } -trait Show for Int { fn show(self) -> String { "a-int {self}" } } -pub fn show_int(x: Int) -> String { x.show() } -pub fn use_show(x: t) -> String where t: Show { x.show() } diff --git a/tests/golden/lang/traits/same_named_traits_deferred_ambiguous/b.silt b/tests/golden/lang/traits/same_named_traits_deferred_ambiguous/b.silt deleted file mode 100644 index fb3808b31..000000000 --- a/tests/golden/lang/traits/same_named_traits_deferred_ambiguous/b.silt +++ /dev/null @@ -1,4 +0,0 @@ -pub trait Show { fn show(self) -> String } -trait Show for Int { fn show(self) -> String { "b-int {self}" } } -pub fn show_int(x: Int) -> String { x.show() } -pub fn use_show(x: t) -> String where t: Show { x.show() } diff --git a/tests/golden/lang/traits/same_named_traits_deferred_ambiguous/main.silt b/tests/golden/lang/traits/same_named_traits_deferred_ambiguous/main.silt deleted file mode 100644 index 484a26b44..000000000 --- a/tests/golden/lang/traits/same_named_traits_deferred_ambiguous/main.silt +++ /dev/null @@ -1,12 +0,0 @@ --- exit: 1 --- A method call on a receiver that becomes Int only once the function --- is inferred, here where both modules' trait `Show` are seen, is --- ambiguous: an error at the call. --- stderr-contains: error[type]: ambiguous method 'show' on type 'Int': provided by traits a.Show, b.Show --- stderr-contains: --> main.silt:11:34 -import a -import b -import list -fn main() { - println([5] |> list.map { y -> y.show() }) -} diff --git a/tests/golden/lang/traits/same_named_traits_deferred_receiver/a.silt b/tests/golden/lang/traits/same_named_traits_deferred_receiver/a.silt index 664e1cbdb..a7703ec72 100644 --- a/tests/golden/lang/traits/same_named_traits_deferred_receiver/a.silt +++ b/tests/golden/lang/traits/same_named_traits_deferred_receiver/a.silt @@ -1,4 +1,4 @@ pub trait Show { fn show(self) -> String } trait Show for Int { fn show(self) -> String { "a-int {self}" } } -pub fn show_int(x: Int) -> String { x.show() } -pub fn use_show(x: t) -> String where t: Show { x.show() } +pub fn show_int(x: Int) -> String { Show.show(x) } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_deferred_receiver/b.silt b/tests/golden/lang/traits/same_named_traits_deferred_receiver/b.silt index fb3808b31..3184cccb3 100644 --- a/tests/golden/lang/traits/same_named_traits_deferred_receiver/b.silt +++ b/tests/golden/lang/traits/same_named_traits_deferred_receiver/b.silt @@ -1,4 +1,4 @@ pub trait Show { fn show(self) -> String } trait Show for Int { fn show(self) -> String { "b-int {self}" } } -pub fn show_int(x: Int) -> String { x.show() } -pub fn use_show(x: t) -> String where t: Show { x.show() } +pub fn show_int(x: Int) -> String { Show.show(x) } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_deferred_receiver/helper.silt b/tests/golden/lang/traits/same_named_traits_deferred_receiver/helper.silt index da1c5bff6..d81a7b7dd 100644 --- a/tests/golden/lang/traits/same_named_traits_deferred_receiver/helper.silt +++ b/tests/golden/lang/traits/same_named_traits_deferred_receiver/helper.silt @@ -1,2 +1,2 @@ import b -pub fn via_b(x: Int) -> String { x.show() } +pub fn via_b(x: Int) -> String { b.Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_deferred_receiver/main.silt b/tests/golden/lang/traits/same_named_traits_deferred_receiver/main.silt index d82ba6e4c..c01dcbcb1 100644 --- a/tests/golden/lang/traits/same_named_traits_deferred_receiver/main.silt +++ b/tests/golden/lang/traits/same_named_traits_deferred_receiver/main.silt @@ -6,6 +6,6 @@ import a import helper import list fn main() { - println([5] |> list.map { y -> y.show() }) + println([5] |> list.map { y -> a.Show.show(y) }) println(helper.via_b(6)) } diff --git a/tests/golden/lang/traits/same_named_traits_deferred_receiver_has_no_field/a.silt b/tests/golden/lang/traits/same_named_traits_deferred_receiver_has_no_field/a.silt new file mode 100644 index 000000000..a7703ec72 --- /dev/null +++ b/tests/golden/lang/traits/same_named_traits_deferred_receiver_has_no_field/a.silt @@ -0,0 +1,4 @@ +pub trait Show { fn show(self) -> String } +trait Show for Int { fn show(self) -> String { "a-int {self}" } } +pub fn show_int(x: Int) -> String { Show.show(x) } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_deferred_receiver_has_no_field/b.silt b/tests/golden/lang/traits/same_named_traits_deferred_receiver_has_no_field/b.silt new file mode 100644 index 000000000..3184cccb3 --- /dev/null +++ b/tests/golden/lang/traits/same_named_traits_deferred_receiver_has_no_field/b.silt @@ -0,0 +1,4 @@ +pub trait Show { fn show(self) -> String } +trait Show for Int { fn show(self) -> String { "b-int {self}" } } +pub fn show_int(x: Int) -> String { Show.show(x) } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_deferred_receiver_has_no_field/main.silt b/tests/golden/lang/traits/same_named_traits_deferred_receiver_has_no_field/main.silt new file mode 100644 index 000000000..7c67f9bc8 --- /dev/null +++ b/tests/golden/lang/traits/same_named_traits_deferred_receiver_has_no_field/main.silt @@ -0,0 +1,13 @@ +-- exit: 1 +-- A dot after a value whose type becomes Int only once the closure is +-- inferred names a field, which Int has not, where both modules' trait +-- `Show` have a method `show`: the help names the first. +-- stderr-contains: error[type]: type 'Int' has no field 'show' +-- stderr-contains: help: `show` is a method of trait `a.Show`: call it as `a.Show.show(y)` +-- stderr-contains: --> main.silt:12:34 +import a +import b +import list +fn main() { + println([5] |> list.map { y -> y.show() }) +} diff --git a/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/a.silt b/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/a.silt new file mode 100644 index 000000000..a7703ec72 --- /dev/null +++ b/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/a.silt @@ -0,0 +1,4 @@ +pub trait Show { fn show(self) -> String } +trait Show for Int { fn show(self) -> String { "a-int {self}" } } +pub fn show_int(x: Int) -> String { Show.show(x) } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/b.silt b/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/b.silt new file mode 100644 index 000000000..3184cccb3 --- /dev/null +++ b/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/b.silt @@ -0,0 +1,4 @@ +pub trait Show { fn show(self) -> String } +trait Show for Int { fn show(self) -> String { "b-int {self}" } } +pub fn show_int(x: Int) -> String { Show.show(x) } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/case.stdout b/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/case.stdout new file mode 100644 index 000000000..89159bfb3 --- /dev/null +++ b/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/case.stdout @@ -0,0 +1,4 @@ +a-int 5 +b-int 6 +a-int 7 +b-int 8 diff --git a/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/main.silt b/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/main.silt new file mode 100644 index 000000000..a5a7c5a0c --- /dev/null +++ b/tests/golden/lang/traits/same_named_traits_told_apart_by_the_trait/main.silt @@ -0,0 +1,10 @@ +-- Two modules each declare a trait `Show` with `fn show` and implement +-- it for Int. A call names the trait it means, so both are called here. +import a +import b +fn main() { + println(a.Show.show(5)) + println(b.Show.show(6)) + println(a.use_show(7)) + println(b.use_show(8)) +} diff --git a/tests/golden/lang/traits/same_named_traits_two_modules/a.silt b/tests/golden/lang/traits/same_named_traits_two_modules/a.silt index 664e1cbdb..a7703ec72 100644 --- a/tests/golden/lang/traits/same_named_traits_two_modules/a.silt +++ b/tests/golden/lang/traits/same_named_traits_two_modules/a.silt @@ -1,4 +1,4 @@ pub trait Show { fn show(self) -> String } trait Show for Int { fn show(self) -> String { "a-int {self}" } } -pub fn show_int(x: Int) -> String { x.show() } -pub fn use_show(x: t) -> String where t: Show { x.show() } +pub fn show_int(x: Int) -> String { Show.show(x) } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_two_modules/b.silt b/tests/golden/lang/traits/same_named_traits_two_modules/b.silt index fb3808b31..3184cccb3 100644 --- a/tests/golden/lang/traits/same_named_traits_two_modules/b.silt +++ b/tests/golden/lang/traits/same_named_traits_two_modules/b.silt @@ -1,4 +1,4 @@ pub trait Show { fn show(self) -> String } trait Show for Int { fn show(self) -> String { "b-int {self}" } } -pub fn show_int(x: Int) -> String { x.show() } -pub fn use_show(x: t) -> String where t: Show { x.show() } +pub fn show_int(x: Int) -> String { Show.show(x) } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_unbounded_call/a.silt b/tests/golden/lang/traits/same_named_traits_unbounded_call/a.silt deleted file mode 100644 index 664e1cbdb..000000000 --- a/tests/golden/lang/traits/same_named_traits_unbounded_call/a.silt +++ /dev/null @@ -1,4 +0,0 @@ -pub trait Show { fn show(self) -> String } -trait Show for Int { fn show(self) -> String { "a-int {self}" } } -pub fn show_int(x: Int) -> String { x.show() } -pub fn use_show(x: t) -> String where t: Show { x.show() } diff --git a/tests/golden/lang/traits/same_named_traits_unbounded_call/b.silt b/tests/golden/lang/traits/same_named_traits_unbounded_call/b.silt deleted file mode 100644 index fb3808b31..000000000 --- a/tests/golden/lang/traits/same_named_traits_unbounded_call/b.silt +++ /dev/null @@ -1,4 +0,0 @@ -pub trait Show { fn show(self) -> String } -trait Show for Int { fn show(self) -> String { "b-int {self}" } } -pub fn show_int(x: Int) -> String { x.show() } -pub fn use_show(x: t) -> String where t: Show { x.show() } diff --git a/tests/golden/lang/traits/same_named_traits_unbounded_call/main.silt b/tests/golden/lang/traits/same_named_traits_unbounded_call/main.silt deleted file mode 100644 index f3812a0d3..000000000 --- a/tests/golden/lang/traits/same_named_traits_unbounded_call/main.silt +++ /dev/null @@ -1,11 +0,0 @@ --- exit: 1 --- A method call on a receiver of unknown type means the one trait in --- sight that declares the method. Where two do, the receiver needs an --- annotation. --- stderr-contains: error[type]: ambiguous method 'show' on type 'Int': provided by traits a.Show, b.Show -import a -import b -fn main() { - let g = { y -> y.show() } - println(g(5)) -} diff --git a/tests/golden/lang/traits/same_named_traits_unknown_receiver_reads_a_field/a.silt b/tests/golden/lang/traits/same_named_traits_unknown_receiver_reads_a_field/a.silt new file mode 100644 index 000000000..a7703ec72 --- /dev/null +++ b/tests/golden/lang/traits/same_named_traits_unknown_receiver_reads_a_field/a.silt @@ -0,0 +1,4 @@ +pub trait Show { fn show(self) -> String } +trait Show for Int { fn show(self) -> String { "a-int {self}" } } +pub fn show_int(x: Int) -> String { Show.show(x) } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_unknown_receiver_reads_a_field/b.silt b/tests/golden/lang/traits/same_named_traits_unknown_receiver_reads_a_field/b.silt new file mode 100644 index 000000000..3184cccb3 --- /dev/null +++ b/tests/golden/lang/traits/same_named_traits_unknown_receiver_reads_a_field/b.silt @@ -0,0 +1,4 @@ +pub trait Show { fn show(self) -> String } +trait Show for Int { fn show(self) -> String { "b-int {self}" } } +pub fn show_int(x: Int) -> String { Show.show(x) } +pub fn use_show(x: t) -> String where t: Show { Show.show(x) } diff --git a/tests/golden/lang/traits/same_named_traits_unknown_receiver_reads_a_field/main.silt b/tests/golden/lang/traits/same_named_traits_unknown_receiver_reads_a_field/main.silt new file mode 100644 index 000000000..4a9f7af98 --- /dev/null +++ b/tests/golden/lang/traits/same_named_traits_unknown_receiver_reads_a_field/main.silt @@ -0,0 +1,11 @@ +-- exit: 1 +-- A dot after a value of unknown type is a field: `g` takes a record +-- with a field `show`, whatever traits in sight have a method `show`. +-- stderr-contains: error[type]: type 'Int' has no field 'show' +-- stderr-contains: help: `show` is a method of trait `a.Show`: call it as `a.Show.show(x)` +import a +import b +fn main() { + let g = { y -> y.show() } + println(g(5)) +} diff --git a/tests/golden/lang/traits/static_method__called_on_bound_value.silt b/tests/golden/lang/traits/static_method__called_on_bound_value.silt index 7d81038ba..3dc1ffd0c 100644 --- a/tests/golden/lang/traits/static_method__called_on_bound_value.silt +++ b/tests/golden/lang/traits/static_method__called_on_bound_value.silt @@ -1,9 +1,10 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: method `total` takes no `self` — call it on the type instead: `b.total()`, where `b` is a `type b` parameter +-- stderr-contains: error[type]: type 'b' has no field 'total' +-- stderr-contains: help: `total` is a method of trait `Vals` that makes a value: call it on the type, `b.total()`, where `b` is a `type b` parameter -- stderr-not-contains: panicked --- A method the trait declares without `self` is called on a type. On a --- value of a bounded type variable it is an error of the call (the +-- A method the trait declares without `self` is called on a type: a +-- value of a bounded type variable has no field of its name (the -- checker used to panic here). trait Vals { fn total() -> Int diff --git a/tests/golden/lang/traits/static_method__called_on_unknown_receiver.silt b/tests/golden/lang/traits/static_method__called_on_unknown_receiver.silt index ff7f72ae3..15796a84a 100644 --- a/tests/golden/lang/traits/static_method__called_on_unknown_receiver.silt +++ b/tests/golden/lang/traits/static_method__called_on_unknown_receiver.silt @@ -1,11 +1,12 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: method `total` takes no `self` — call it on the type instead: `SomeType.total()` --- stderr-contains: :20:3 --- stderr-contains: :28:18 --- A receiver whose type is not known where the call is written: the one --- trait that declares `total` declares it without `self`, so the call is --- refused (it used to check, and fail when run). +-- stderr-contains: error[type]: type 'Int' has no field 'total' +-- stderr-contains: help: `total` is a method of trait `Vals` that makes a value: call it on the type, `Int.total()` +-- stderr-contains: :30:14 +-- stderr-contains: :31:13 +-- A receiver whose type is not known where the call is written takes a +-- record with a field `total`: an Int has none (it used to check, and +-- fail when run). trait Vals { fn total() -> Int } diff --git a/tests/golden/lang/traits/static_method__impl_adds_self.silt b/tests/golden/lang/traits/static_method__impl_adds_self.silt index cc5c8dbba..c104e2976 100644 --- a/tests/golden/lang/traits/static_method__impl_adds_self.silt +++ b/tests/golden/lang/traits/static_method__impl_adds_self.silt @@ -2,7 +2,7 @@ -- exit: 1 -- stderr-contains: error[type]: method `total` takes 1 parameter in this impl, but trait `Vals` declares it with 0 -- stderr-contains: help: trait `Vals` declares `total` without `self`: it is called on the type (`Int.total()`), not on a value --- stderr-contains: error[type]: method `total` takes no `self` +-- stderr-contains: error[type]: type 'b' has no field 'total' -- stderr-not-contains: panicked trait Vals { fn total() -> Int diff --git a/tests/golden/lang/traits/static_method__impl_drops_self.silt b/tests/golden/lang/traits/static_method__impl_drops_self.silt index 5a82cb8c0..35a3a49fd 100644 --- a/tests/golden/lang/traits/static_method__impl_drops_self.silt +++ b/tests/golden/lang/traits/static_method__impl_drops_self.silt @@ -19,5 +19,5 @@ trait Vals for Int { } fn main() { - println(7.total()) + println(Vals.total(7)) } diff --git a/tests/golden/lang/traits/static_method__method_called_on_the_type.silt b/tests/golden/lang/traits/static_method__method_called_on_the_type.silt index 206927bcc..f3ab1f6a9 100644 --- a/tests/golden/lang/traits/static_method__method_called_on_the_type.silt +++ b/tests/golden/lang/traits/static_method__method_called_on_the_type.silt @@ -20,8 +20,8 @@ fn zero_of(type b) -> b where b: Vals { } fn main() { - println(Int.total(7)) - println(7.total()) + println(Vals.total(7)) + println(Vals.total(7)) println(Int.zero()) println(zero_of(Int)) } diff --git a/tests/golden/lang/traits/static_method__with_parameters_on_a_bounded_value.silt b/tests/golden/lang/traits/static_method__with_parameters_on_a_bounded_value.silt index d27bb1344..f761725f8 100644 --- a/tests/golden/lang/traits/static_method__with_parameters_on_a_bounded_value.silt +++ b/tests/golden/lang/traits/static_method__with_parameters_on_a_bounded_value.silt @@ -1,11 +1,12 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: method `make` takes no `self` — call it on the type instead: `a.make(..)`, where `a` is a `type a` parameter --- stderr-contains: error[type]: method `join` takes no `self` — call it on the type instead: `a.join(..)`, where `a` is a `type a` parameter --- stderr-contains: :28:3 --- stderr-contains: :32:3 --- stderr-contains: :36:3 --- The same through a bound: a value of a bounded type variable. +-- stderr-contains: help: `make` is a method of trait `Mk` that makes a value: call it on the type, `a.make(..)`, where `a` is a `type a` parameter +-- stderr-contains: help: `join` is a method of trait `Mk`: call it as `Mk.join(x, ..)` +-- stderr-contains: :29:3 +-- stderr-contains: :33:3 +-- stderr-contains: :37:3 +-- The same through a bound: a value of a bounded type variable has no +-- fields; `join`, which takes Self, is called through its trait. trait Mk { fn make(n: Int) -> Self fn join(a: Self, b: Self) -> Self diff --git a/tests/golden/lang/traits/static_method__with_parameters_on_a_value.silt b/tests/golden/lang/traits/static_method__with_parameters_on_a_value.silt index ddeb9167b..61a097460 100644 --- a/tests/golden/lang/traits/static_method__with_parameters_on_a_value.silt +++ b/tests/golden/lang/traits/static_method__with_parameters_on_a_value.silt @@ -1,16 +1,16 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: method `make` takes no `self` — call it on the type instead: `Int.make(..)` --- stderr-contains: error[type]: method `join` takes no `self` — call it on the type instead: `Int.join(..)` +-- stderr-contains: help: `make` is a method of trait `Mk` that makes a value: call it on the type, `Int.make(..)` +-- stderr-contains: help: `join` is a method of trait `Mk`: call it as `Mk.join(x, ..)` -- stderr-contains: :33:11 -- stderr-contains: :34:11 -- stderr-contains: :35:11 -- stderr-contains: :36:11 -- stderr-not-contains: expects --- A method without `self` is called on the type, whatever parameters it --- has: on a value of the type it is refused, with one argument too few --- (it used to check and run, the receiver taken for the first --- parameter) and with all of them (it was "expects 0 arguments"). +-- A dot after a value is a field, whatever methods its type has: a +-- method that makes a value is called on the type, one that takes Self +-- through its trait (a call on a value used to take the receiver for +-- the first parameter, or say "expects 0 arguments"). trait Mk { fn make(n: Int) -> Self fn join(a: Self, b: Self) -> Self diff --git a/tests/golden/lang/traits/static_method__with_parameters_on_an_unknown_receiver.silt b/tests/golden/lang/traits/static_method__with_parameters_on_an_unknown_receiver.silt index c4a715e7c..a81059ea4 100644 --- a/tests/golden/lang/traits/static_method__with_parameters_on_an_unknown_receiver.silt +++ b/tests/golden/lang/traits/static_method__with_parameters_on_an_unknown_receiver.silt @@ -1,12 +1,12 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: method `make` takes no `self` — call it on the type instead: `SomeType.make(..)` --- stderr-contains: error[type]: method `join` takes no `self` — call it on the type instead: `SomeType.join(..)` --- stderr-contains: :29:3 --- stderr-contains: :33:3 +-- stderr-contains: error[type]: type 'Int' has no field 'make' +-- stderr-contains: error[type]: type 'Int' has no field 'join' +-- stderr-contains: :37:15 +-- stderr-contains: :38:15 -- The same for a receiver whose type is not known where the call is --- written (it used to check, and fail when run: "function 'Int.make' --- expects 1 arguments, got 2"). +-- written: it takes a record with the field (it used to check, and fail +-- when run: "function 'Int.make' expects 1 arguments, got 2"). trait Mk { fn make(n: Int) -> Self fn join(a: Self, b: Self) -> Self diff --git a/tests/golden/lang/traits/static_method__with_parameters_on_the_type.silt b/tests/golden/lang/traits/static_method__with_parameters_on_the_type.silt index e9efdd214..74ffc5d9e 100644 --- a/tests/golden/lang/traits/static_method__with_parameters_on_the_type.silt +++ b/tests/golden/lang/traits/static_method__with_parameters_on_the_type.silt @@ -20,15 +20,15 @@ trait Mk for Int { } fn build(n: Int, type a) -> a where a: Mk { - a.make(n).twice() + Mk.twice(a.make(n)) } fn main() { println(Int.make(4)) - println(Int.join(1, 2)) + println(Mk.join(1, 2)) println(build(5, Int)) let f = Int.make println(f(3)) - println(4.twice()) - println(Int.twice(4)) + println(Mk.twice(4)) + println(Mk.twice(4)) } diff --git a/tests/golden/lang/traits/structural__equal_compare_hash_agree.silt b/tests/golden/lang/traits/structural__equal_compare_hash_agree.silt index 1a79713ef..74cca7198 100644 --- a/tests/golden/lang/traits/structural__equal_compare_hash_agree.silt +++ b/tests/golden/lang/traits/structural__equal_compare_hash_agree.silt @@ -28,15 +28,15 @@ fn lt(x: a, y: a) -> Bool where a: Compare { } fn cmp(x: a, y: a) -> Int where a: Compare { - x.compare(y) + Compare.compare(x, y) } fn same(x: a, y: a) -> Bool where a: Equal { - x == y && x.equal(y) + x == y && (x == y) } fn hashes(x: a, y: a) -> Bool where a: Hash { - x.hash() == y.hash() + Hash.hash(x) == Hash.hash(y) } fn main() { @@ -44,24 +44,24 @@ fn main() { let b = Version { minor: 2, major: 0 } -- `minor` is declared first: it decides. println(a < b) - println(a.compare(b)) + println(Compare.compare(a, b)) println(lt(a, b)) println(cmp(b, a)) - println(Version.compare(a, a)) + println(Compare.compare(a, a)) println(list.sort([b, a, b]) == [a, b, b]) -- Variants by declaration, then payload. println(Square(9) < Circle(0)) - println(Circle(1).compare(Circle(2))) + println(Compare.compare(Circle(1), Circle(2))) println(cmp(Dot, Square(1))) println(list.sort([Dot, Circle(2), Square(3), Circle(1)])) -- Equal and Hash agree, alone and inside containers. let x = Tagged { tag: "t", item: [Some(a), None] } let y = Tagged { tag: "t", item: [Some(Version { minor: 1, major: 9 }), None] } println(x == y) - println(x.equal(y)) + println(x == y) println(same(x, y)) println(hashes(x, y)) - println(x.hash() == y.hash()) + println(Hash.hash(x) == Hash.hash(y)) println(set.length(#[x, y])) println(map.get(#{x: "found"}, y)) println((a, [Dot]) == (a, [Dot])) @@ -69,9 +69,9 @@ fn main() { println(same(x, Tagged { tag: "u", item: [] })) -- Floats: 0.0 and -0.0 are equal, hash alike and order as equal. println(0.0 == -0.0) - println(0.0.equal(-0.0)) + println(0.0 == -0.0) println(hashes(0.0, -0.0)) - println(0.0.compare(-0.0)) + println(Compare.compare(0.0, -0.0)) println(set.length(#[0.0, -0.0])) println([1.5, -0.0] == [1.5, 0.0]) println(1.5 < 2.5 && cmp(1.5, 2.5) == -1) diff --git a/tests/golden/lang/traits/through_the_type__a_method_that_takes_self.silt b/tests/golden/lang/traits/through_the_type__a_method_that_takes_self.silt new file mode 100644 index 000000000..5eb725424 --- /dev/null +++ b/tests/golden/lang/traits/through_the_type__a_method_that_takes_self.silt @@ -0,0 +1,22 @@ +-- cmd: check +-- exit: 1 +-- A method that takes a value of the type is called through its trait: +-- through the type it is an error, also through a `type a` parameter, +-- and for the builtin traits; a method that makes a value is called +-- through the type. +trait Monoid { + fn empty() -> Self + fn combine(a: Self, b: Self) -> Self +} +trait Monoid for Int { + fn empty() -> Self { 0 } + fn combine(a: Self, b: Self) -> Self { a + b } +} +fn sum(x: a, y: a, type a) -> a where a: Monoid { a.combine(x, y) } +fn main() { + println(Int.combine(1, 2)) + println(Int.empty()) + println(sum(1, 2, Int)) + println(Int.compare(1, 2)) + println(Int.display(1)) +} diff --git a/tests/golden/lang/traits/through_the_type__a_method_that_takes_self.stderr b/tests/golden/lang/traits/through_the_type__a_method_that_takes_self.stderr new file mode 100644 index 000000000..57538ba4d --- /dev/null +++ b/tests/golden/lang/traits/through_the_type__a_method_that_takes_self.stderr @@ -0,0 +1,27 @@ +error[type]: type 'a' has no method 'combine' + --> through_the_type__a_method_that_takes_self.silt:15:51 + | + 15 | fn sum(x: a, y: a, type a) -> a where a: Monoid { a.combine(x, y) } + | ^^^^^^^^^ type 'a' has no method 'combine' + = help: `combine` is a method of trait `Monoid`: call it as `Monoid.combine(x, ..)` + +error[type]: type 'Int' has no method 'combine' + --> through_the_type__a_method_that_takes_self.silt:17:11 + | + 17 | println(Int.combine(1, 2)) + | ^^^^^^^^^^^ type 'Int' has no method 'combine' + = help: `combine` is a method of trait `Monoid`: call it as `Monoid.combine(x, ..)` + +error[type]: type 'Int' has no method 'compare' + --> through_the_type__a_method_that_takes_self.silt:20:11 + | + 20 | println(Int.compare(1, 2)) + | ^^^^^^^^^^^ type 'Int' has no method 'compare' + = help: `compare` is a method of trait `Compare`: call it as `Compare.compare(x, ..)` + +error[type]: type 'Int' has no method 'display' + --> through_the_type__a_method_that_takes_self.silt:21:11 + | + 21 | println(Int.display(1)) + | ^^^^^^^^^^^ type 'Int' has no method 'display' + = help: show a value with interpolation, `"{x}"`, or with `string.from(x)` diff --git a/tests/golden/lang/traits/trait_call__private_trait/case.stderr b/tests/golden/lang/traits/trait_call__private_trait/case.stderr new file mode 100644 index 000000000..c21d283d3 --- /dev/null +++ b/tests/golden/lang/traits/trait_call__private_trait/case.stderr @@ -0,0 +1,6 @@ +error[type]: 'Secret' is private to module 'shapes' + --> main.silt:7:11 + | + 7 | println(shapes.Secret.secret(shapes.square(1))) + | ^^^^^^^^^^^^^ 'Secret' is private to module 'shapes' + = help: mark it `pub` in module 'shapes' to import it from another module diff --git a/tests/golden/lang/traits/trait_call__private_trait/main.silt b/tests/golden/lang/traits/trait_call__private_trait/main.silt new file mode 100644 index 000000000..02bb19562 --- /dev/null +++ b/tests/golden/lang/traits/trait_call__private_trait/main.silt @@ -0,0 +1,8 @@ +-- cmd: check +-- exit: 1 +-- A private trait of another module cannot be named, so its methods +-- cannot be called there. +import shapes +fn main() { + println(shapes.Secret.secret(shapes.square(1))) +} diff --git a/tests/golden/lang/traits/trait_call__private_trait/shapes.silt b/tests/golden/lang/traits/trait_call__private_trait/shapes.silt new file mode 100644 index 000000000..33b7283ca --- /dev/null +++ b/tests/golden/lang/traits/trait_call__private_trait/shapes.silt @@ -0,0 +1,8 @@ +pub type Square { side: Int } +trait Secret { + fn secret(self) -> Int +} +trait Secret for Square { + fn secret(self) -> Int { 42 } +} +pub fn square(n: Int) -> Square { Square { side: n } } diff --git a/tests/golden/lang/traits/trait_call__qualified_and_imported/case.stdout b/tests/golden/lang/traits/trait_call__qualified_and_imported/case.stdout new file mode 100644 index 000000000..a0a1bccd4 --- /dev/null +++ b/tests/golden/lang/traits/trait_call__qualified_and_imported/case.stdout @@ -0,0 +1,5 @@ +9 +9 +18 +hello 1 +hail 1 diff --git a/tests/golden/lang/traits/trait_call__qualified_and_imported/main.silt b/tests/golden/lang/traits/trait_call__qualified_and_imported/main.silt new file mode 100644 index 000000000..9e40db156 --- /dev/null +++ b/tests/golden/lang/traits/trait_call__qualified_and_imported/main.silt @@ -0,0 +1,19 @@ +-- A trait of another module is named as any of its items: +-- `shapes.Area.area`, or `Area.area` after `import shapes.{ Area }`. Two +-- traits that give Int a method of one name are told apart by their +-- names. +import shapes +import other +import shapes.{ Area } +trait Greet { fn greet(self) -> String } +trait Hail { fn greet(self) -> String } +trait Greet for Int { fn greet(self) -> String { "hello {self}" } } +trait Hail for Int { fn greet(self) -> String { "hail {self}" } } +fn main() { + let s = shapes.square(3) + println(shapes.Area.area(s)) + println(Area.area(s)) + println(other.twice(s)) + println(Greet.greet(1)) + println(Hail.greet(1)) +} diff --git a/tests/golden/lang/traits/trait_call__qualified_and_imported/other.silt b/tests/golden/lang/traits/trait_call__qualified_and_imported/other.silt new file mode 100644 index 000000000..2a705711c --- /dev/null +++ b/tests/golden/lang/traits/trait_call__qualified_and_imported/other.silt @@ -0,0 +1,2 @@ +import shapes.{ Area } +pub fn twice(s: a) -> Int where a: Area { Area.area(s) * 2 } diff --git a/tests/golden/lang/traits/trait_call__qualified_and_imported/shapes.silt b/tests/golden/lang/traits/trait_call__qualified_and_imported/shapes.silt new file mode 100644 index 000000000..976e81187 --- /dev/null +++ b/tests/golden/lang/traits/trait_call__qualified_and_imported/shapes.silt @@ -0,0 +1,14 @@ +pub type Square { side: Int } +pub trait Area { + fn area(self) -> Int +} +trait Secret { + fn secret(self) -> Int +} +trait Area for Square { + fn area(self) -> Int { self.side * self.side } +} +trait Secret for Square { + fn secret(self) -> Int { 42 } +} +pub fn square(n: Int) -> Square { Square { side: n } } diff --git a/tests/golden/lang/traits/trait_call__refused.silt b/tests/golden/lang/traits/trait_call__refused.silt new file mode 100644 index 000000000..4d11ba473 --- /dev/null +++ b/tests/golden/lang/traits/trait_call__refused.silt @@ -0,0 +1,28 @@ +-- cmd: check +-- exit: 1 +-- What a call through a trait refuses: a method the trait does not +-- have, Display's and Equal's methods (interpolation and == do that), +-- a method that takes no value of the type (it is called on a type), +-- and an argument whose type has no impl, also through an +-- unannotated function that calls it, and a call with too many +-- arguments, which counts the one of type Self. +trait Greet { + fn greet(self) -> String +} +trait Greet for Int { + fn greet(self) -> String { "int {self}" } +} +trait Monoid { + fn empty() -> Self +} +fn hello(x) { Greet.greet(x) } +fn main() { + println(Greet.gret(5)) + println(Display.display(5)) + println(Equal.equal(5, 5)) + let e = Monoid.empty() + println(Greet.greet("s")) + println(hello("t")) + println(Greet.greet(1, 2)) + println(2 |> Greet.greet(1)) +} diff --git a/tests/golden/lang/traits/trait_call__refused.stderr b/tests/golden/lang/traits/trait_call__refused.stderr new file mode 100644 index 000000000..4e15378ea --- /dev/null +++ b/tests/golden/lang/traits/trait_call__refused.stderr @@ -0,0 +1,51 @@ +error[type]: trait 'Greet' has no method 'gret' + --> trait_call__refused.silt:20:11 + | + 20 | println(Greet.gret(5)) + | ^^^^^^^^^^ trait 'Greet' has no method 'gret' + = help: did you mean 'greet'? + +error[type]: trait 'Display' has no callable methods + --> trait_call__refused.silt:21:11 + | + 21 | println(Display.display(5)) + | ^^^^^^^^^^^^^^^ trait 'Display' has no callable methods + = help: show a value with interpolation, `"{x}"`, or with `string.from(x)` + +error[type]: trait 'Equal' has no callable methods + --> trait_call__refused.silt:22:11 + | + 22 | println(Equal.equal(5, 5)) + | ^^^^^^^^^^^ trait 'Equal' has no callable methods + = help: compare with `==`: `x == y` + +error[type]: method 'empty' of trait 'Monoid' takes no value of the type, so it is called on a type + --> trait_call__refused.silt:23:11 + | + 23 | let e = Monoid.empty() + | ^^^^^^^^^^^^ method 'empty' of trait 'Monoid' takes no value of the type, so it is called on a type + = help: call it on a type, `T.empty()`, or on a `type a` parameter, `a.empty()` + +error[type]: type 'String' does not implement trait 'Greet' + --> trait_call__refused.silt:24:23 + | + 24 | println(Greet.greet("s")) + | ^^^ type 'String' does not implement trait 'Greet' + +error[type]: type 'String' does not implement trait 'Greet' + --> trait_call__refused.silt:25:17 + | + 25 | println(hello("t")) + | ^^^ type 'String' does not implement trait 'Greet' + +error[type]: `Greet.greet` expects 1 argument, got 2 + --> trait_call__refused.silt:26:11 + | + 26 | println(Greet.greet(1, 2)) + | ^^^^^^^^^^^^^^^^^ `Greet.greet` expects 1 argument, got 2 + +error[type]: `Greet.greet` expects 1 argument, got 2 + --> trait_call__refused.silt:27:11 + | + 27 | println(2 |> Greet.greet(1)) + | ^^^^^^^^^^^^^^^^^^^ `Greet.greet` expects 1 argument, got 2 diff --git a/tests/golden/lang/traits/trait_call__self_not_first.silt b/tests/golden/lang/traits/trait_call__self_not_first.silt new file mode 100644 index 000000000..7a494fa8f --- /dev/null +++ b/tests/golden/lang/traits/trait_call__self_not_first.silt @@ -0,0 +1,29 @@ +-- A method whose argument of type Self is not its first is called +-- through its trait like any other: the impl is the one for that +-- argument's type, known where the call is written or found where it +-- runs (a bounded type variable, a closure's parameter, a function +-- value, a piped value). +import list +trait Scale { + fn scale(by: Int, x: Self) -> Self +} +trait Scale for Int { + fn scale(by: Int, x: Self) -> Self { by * x } +} +type V { n: Int } +trait Scale for V { + fn scale(by: Int, x: Self) -> Self { V { n: by + x.n } } +} +fn twice(x: a) -> a where a: Scale { Scale.scale(2, x) } +fn last(x: a) -> a where a: Scale { Scale.scale(3, x) } +fn main() { + println(Scale.scale(2, 5)) + println(Scale.scale(2, V { n: 1 })) + println(twice(5)) + println(twice(V { n: 1 })) + println(list.map([1, 2], { x -> Scale.scale(10, x) })) + let f = Scale.scale + println(f(3, V { n: 4 })) + println(2 |> Scale.scale(V { n: 7 })) + println(last(V { n: 0 })) +} diff --git a/tests/golden/lang/traits/trait_call__self_not_first.stdout b/tests/golden/lang/traits/trait_call__self_not_first.stdout new file mode 100644 index 000000000..92115b10d --- /dev/null +++ b/tests/golden/lang/traits/trait_call__self_not_first.stdout @@ -0,0 +1,8 @@ +10 +V {n: 3} +10 +V {n: 3} +[10, 20] +V {n: 7} +V {n: 9} +V {n: 3} diff --git a/tests/golden/lang/traits/trait_call__supertrait_and_default_bodies.silt b/tests/golden/lang/traits/trait_call__supertrait_and_default_bodies.silt new file mode 100644 index 000000000..900f9a031 --- /dev/null +++ b/tests/golden/lang/traits/trait_call__supertrait_and_default_bodies.silt @@ -0,0 +1,19 @@ +-- A default body and a function bounded by a subtrait call the +-- supertrait's method through the supertrait. +trait Eq2 { + fn eq2(self, other: Self) -> Bool +} +trait Cmp2: Eq2 { + fn lt2(self, other: Self) -> Bool + fn le2(self, other: Self) -> Bool { Eq2.eq2(self, other) || Cmp2.lt2(self, other) } +} +trait Eq2 for Int { fn eq2(self, other: Self) -> Bool { self == other } } +trait Cmp2 for Int { fn lt2(self, other: Self) -> Bool { self < other } } +fn check(a: t, b: t) -> Bool where t: Cmp2 { + Eq2.eq2(a, b) || Cmp2.lt2(a, b) +} +fn main() { + println(check(1, 2)) + println(Cmp2.le2(3, 3)) + println(Cmp2.le2(4, 3)) +} diff --git a/tests/golden/lang/traits/trait_call__supertrait_and_default_bodies.stdout b/tests/golden/lang/traits/trait_call__supertrait_and_default_bodies.stdout new file mode 100644 index 000000000..9e8a46acf --- /dev/null +++ b/tests/golden/lang/traits/trait_call__supertrait_and_default_bodies.stdout @@ -0,0 +1,3 @@ +true +true +false diff --git a/tests/golden/lang/traits/trait_call__through_the_trait.silt b/tests/golden/lang/traits/trait_call__through_the_trait.silt new file mode 100644 index 000000000..17c52c564 --- /dev/null +++ b/tests/golden/lang/traits/trait_call__through_the_trait.silt @@ -0,0 +1,52 @@ +-- A method that takes Self is called through its trait, like a module +-- function: directly, piped, as a function value, from a generic function +-- (annotated or not), inside a conditional impl, and for the builtin +-- Compare, Hash and Error. The impl is the one for the type of the +-- argument of type Self. +import list +import io +trait Greet { + fn greet(self) -> String +} +trait Greet for Int { + fn greet(self) -> String { "int {self}" } +} +type Box(a) { Bx(a) } +trait Greet for Box(a) where a: Greet { + fn greet(self) -> String { + match self { Bx(x) -> "box of {Greet.greet(x)}" } + } +} +trait Monoid { + fn empty() -> Self + fn combine(a: Self, b: Self) -> Self +} +trait Monoid for Int { + fn empty() -> Self { 0 } + fn combine(a: Self, b: Self) -> Self { a + b } +} +fn hello(x) { Greet.greet(x) } +fn bounded(x: a) -> String where a: Greet { Greet.greet(x) } +fn sum(xs: List(a), type a) -> a where a: Monoid { + list.fold(xs, a.empty()) { acc, x -> Monoid.combine(acc, x) } +} +fn main() { + println(Greet.greet(5)) + println(5 |> Greet.greet) + println(hello(Bx(3))) + println(bounded(Bx(Bx(1)))) + println(list.map([1, 2], Greet.greet)) + let f = Greet.greet + println(f(Bx(9))) + println(Monoid.combine(2, 3)) + println(sum([1, 2, 3], Int)) + println(Compare.compare(1, 2)) + println(Hash.hash(1) == Hash.hash(1)) + println(list.map([[1], [2, 3]], Hash.hash) |> list.length) + let g = Compare.compare + println(g("b", "a")) + match io.read_file("/nonexistent") { + Ok(_) -> println("?") + Err(e) -> println(Error.message(e)) + } +} diff --git a/tests/golden/lang/traits/trait_call__through_the_trait.stdout b/tests/golden/lang/traits/trait_call__through_the_trait.stdout new file mode 100644 index 000000000..1eb1f9585 --- /dev/null +++ b/tests/golden/lang/traits/trait_call__through_the_trait.stdout @@ -0,0 +1,13 @@ +int 5 +int 5 +box of int 3 +box of box of int 1 +[int 1, int 2] +box of int 9 +5 +6 +-1 +true +2 +1 +file not found: /nonexistent diff --git a/tests/golden/lang/traits/user_trait_method_named_like_builtin_call.silt b/tests/golden/lang/traits/user_trait_method_named_like_builtin_call.silt index 72cad0c21..480a6912d 100644 --- a/tests/golden/lang/traits/user_trait_method_named_like_builtin_call.silt +++ b/tests/golden/lang/traits/user_trait_method_named_like_builtin_call.silt @@ -1,18 +1,16 @@ --- cmd: check --- exit: 1 --- A trait of the program with a method named like a builtin trait's, --- implemented for Int: a call on an Int here sees both traits and is --- ambiguous (prelude traits are always seen); a call through a `where` --- bound names its trait and is not. --- stderr-contains: error[type]: ambiguous method 'display' on type 'Int': provided by traits Describe, Display --- stderr-contains: --> user_trait_method_named_like_builtin_call.silt:16:11 +-- A trait of the program with methods named like a builtin trait's, +-- implemented for Int: a call names its trait, so the program's +-- `Ranked.compare` and the builtin `Compare.compare` are told apart, and +-- the program's `Describe.display` does not change how Int is shown. trait Describe { fn display(self) -> String } trait Describe for Int { fn display(self) -> String { "described {self}" } } trait Ranked { fn compare(self, other: Self) -> Int } trait Ranked for Int { fn compare(self, other: Self) -> Int { 99 } } -fn described(x: t) -> String where t: Describe { x.display() } +fn described(x: t) -> String where t: Describe { Describe.display(x) } fn main() { - println(5.display()) - println(5.compare(6)) + println(Describe.display(5)) + println(Ranked.compare(5, 6)) + println(Compare.compare(5, 6)) println(described(5)) + println(5) } diff --git a/tests/golden/lang/traits/user_trait_method_named_like_builtin_call.stdout b/tests/golden/lang/traits/user_trait_method_named_like_builtin_call.stdout new file mode 100644 index 000000000..9f6ea0de7 --- /dev/null +++ b/tests/golden/lang/traits/user_trait_method_named_like_builtin_call.stdout @@ -0,0 +1,5 @@ +described 5 +99 +-1 +described 5 +5 diff --git a/tests/golden/lang/traits/user_trait_method_named_like_builtin_is_no_builtin_impl.silt b/tests/golden/lang/traits/user_trait_method_named_like_builtin_is_no_builtin_impl.silt index 520ec33dc..cbd81eb9f 100644 --- a/tests/golden/lang/traits/user_trait_method_named_like_builtin_is_no_builtin_impl.silt +++ b/tests/golden/lang/traits/user_trait_method_named_like_builtin_is_no_builtin_impl.silt @@ -8,7 +8,7 @@ trait Describe for Pt { fn display(self) -> String { "described" } } trait Ranked { fn compare(self, other: Self) -> Int } trait Ranked for Pt { fn compare(self, other: Self) -> Int { 99 } } fn show_it(a: a) -> String where a: Display { "{a}" } -fn rank(a: a, b: a) -> Int where a: Ranked { a.compare(b) } +fn rank(a: a, b: a) -> Int where a: Ranked { Ranked.compare(a, b) } fn main() { println("{Pt { x: 1 }}") println(show_it(Pt { x: 2 })) diff --git a/tests/golden/lang/traits/user_trait_method_named_like_builtin_unbounded_call.silt b/tests/golden/lang/traits/user_trait_method_named_like_builtin_unbounded_call.silt deleted file mode 100644 index 3e8f48f13..000000000 --- a/tests/golden/lang/traits/user_trait_method_named_like_builtin_unbounded_call.silt +++ /dev/null @@ -1,12 +0,0 @@ --- exit: 1 --- A method call on a receiver of unknown type means the one trait in --- sight that declares the method: with a program trait that declares --- `display` beside the builtin `Display`, the receiver needs an --- annotation. --- stderr-contains: error[type]: ambiguous method 'display' on type 'Int': provided by traits Describe, Display -trait Describe { fn display(self) -> String } -trait Describe for Int { fn display(self) -> String { "described {self}" } } -fn main() { - let g = { y -> y.display() } - println(g(5)) -} diff --git a/tests/golden/lang/traits/vm_dispatch_unsupportable_field__compare_on_user_record_with_map_field_rejected_statically.silt b/tests/golden/lang/traits/vm_dispatch_unsupportable_field__compare_on_user_record_with_map_field_rejected_statically.silt index a557d78fc..8afff38fa 100644 --- a/tests/golden/lang/traits/vm_dispatch_unsupportable_field__compare_on_user_record_with_map_field_rejected_statically.silt +++ b/tests/golden/lang/traits/vm_dispatch_unsupportable_field__compare_on_user_record_with_map_field_rejected_statically.silt @@ -1,7 +1,7 @@ -- exit: 1 -- stderr-contains: error[type]: type 'Doc' does not implement trait 'Compare': field 'meta' is of type 'Map(String, Int)', which does not type Doc { meta: Map(String, Int) } -fn cmp_gen(x: a, y: a) -> Int where a: Compare { x.compare(y) } +fn cmp_gen(x: a, y: a) -> Int where a: Compare { Compare.compare(x, y) } fn main() { let d = Doc { meta: #{"a": 1} } println(cmp_gen(d, d)) diff --git a/tests/golden/lang/traits/vm_dispatch_unsupportable_field__compare_on_user_record_with_tuple_field_ordered.silt b/tests/golden/lang/traits/vm_dispatch_unsupportable_field__compare_on_user_record_with_tuple_field_ordered.silt index 733e4f277..20584323b 100644 --- a/tests/golden/lang/traits/vm_dispatch_unsupportable_field__compare_on_user_record_with_tuple_field_ordered.silt +++ b/tests/golden/lang/traits/vm_dispatch_unsupportable_field__compare_on_user_record_with_tuple_field_ordered.silt @@ -1,7 +1,7 @@ -- A record with a tuple field is ordered: a tuple has Compare when its -- parts do. type Pair { t: (Int, Int) } -fn cmp_gen(x: a, y: a) -> Int where a: Compare { x.compare(y) } +fn cmp_gen(x: a, y: a) -> Int where a: Compare { Compare.compare(x, y) } fn main() { let p = Pair { t: (1, 2) } println(cmp_gen(p, p)) diff --git a/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_on_user_record_with_channel_field_rejected_statically.silt b/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_on_user_record_with_channel_field_rejected_statically.silt index 84a04a367..801f32de8 100644 --- a/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_on_user_record_with_channel_field_rejected_statically.silt +++ b/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_on_user_record_with_channel_field_rejected_statically.silt @@ -2,7 +2,7 @@ -- stderr-contains: error[type]: type 'Holder' does not implement trait 'Hash': field 'ch' is of type 'Channel(Int)', which does not import channel type Holder { id: String, ch: Channel(Int) } -fn h(x: a) -> Int where a: Hash { x.hash() } +fn h(x: a) -> Int where a: Hash { Hash.hash(x) } fn main() { let c = channel.new(1) let hol = Holder { id: "x", ch: c } diff --git a/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_on_user_variant_with_channel_field_rejected_statically.silt b/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_on_user_variant_with_channel_field_rejected_statically.silt index 9ea984706..c3b753b0b 100644 --- a/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_on_user_variant_with_channel_field_rejected_statically.silt +++ b/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_on_user_variant_with_channel_field_rejected_statically.silt @@ -2,7 +2,7 @@ -- stderr-contains: error[type]: type 'V' does not implement trait 'Hash': variant 'Box1' payload #1 is of type 'Channel(Int)', which does not import channel type V { Box1(Channel(Int)), Other } -fn h(x: a) -> Int where a: Hash { x.hash() } +fn h(x: a) -> Int where a: Hash { Hash.hash(x) } fn main() { let v = Box1(channel.new(1)) println(h(v)) diff --git a/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_runs_on_user_record_with_tuple_field.silt b/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_runs_on_user_record_with_tuple_field.silt index 2349cc354..387ce1a77 100644 --- a/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_runs_on_user_record_with_tuple_field.silt +++ b/tests/golden/lang/traits/vm_dispatch_unsupportable_field__hash_runs_on_user_record_with_tuple_field.silt @@ -5,7 +5,7 @@ import int import result type Pair { t: (Int, Int) } -fn h(x: a) -> Int where a: Hash { x.hash() } +fn h(x: a) -> Int where a: Hash { Hash.hash(x) } fn main() { let p = Pair { t: (1, 2) } let v = h(p) diff --git a/tests/golden/lang/traits/vm_dispatch_variant_record__compare_on_user_record_with_tuple_field_ordered.silt b/tests/golden/lang/traits/vm_dispatch_variant_record__compare_on_user_record_with_tuple_field_ordered.silt index 35221e4cb..40e4467fa 100644 --- a/tests/golden/lang/traits/vm_dispatch_variant_record__compare_on_user_record_with_tuple_field_ordered.silt +++ b/tests/golden/lang/traits/vm_dispatch_variant_record__compare_on_user_record_with_tuple_field_ordered.silt @@ -1,7 +1,7 @@ -- A record with a tuple field is ordered: a tuple has Compare when its -- parts do. type Point { n: Int, t: (Int, Int), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { let p = Point { n: 1, t: (0, 0) } let q = Point { n: 2, t: (0, 0) } diff --git a/tests/golden/lang/traits/vm_dispatch_variant_record__compare_on_user_variant_with_channel_payload_rejected_statically.silt b/tests/golden/lang/traits/vm_dispatch_variant_record__compare_on_user_variant_with_channel_payload_rejected_statically.silt index 8f540d6d1..e66102966 100644 --- a/tests/golden/lang/traits/vm_dispatch_variant_record__compare_on_user_variant_with_channel_payload_rejected_statically.silt +++ b/tests/golden/lang/traits/vm_dispatch_variant_record__compare_on_user_variant_with_channel_payload_rejected_statically.silt @@ -2,5 +2,5 @@ -- stderr-contains: error[type]: type 'Color' does not implement trait 'Compare': variant 'Holding' payload #1 is of type 'Channel(Int)', which does not import channel type Color { Red, Green, Holding(Channel(Int)), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Red, Green)) } diff --git a/tests/golden/lang/traits/vm_dispatch_variant_record__compare_runs_on_builtin_weekday.silt b/tests/golden/lang/traits/vm_dispatch_variant_record__compare_runs_on_builtin_weekday.silt index b49310fe3..11923923c 100644 --- a/tests/golden/lang/traits/vm_dispatch_variant_record__compare_runs_on_builtin_weekday.silt +++ b/tests/golden/lang/traits/vm_dispatch_variant_record__compare_runs_on_builtin_weekday.silt @@ -1,3 +1,3 @@ import time -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(time.Monday, time.Friday)) } diff --git a/tests/golden/lang/traits/vm_dispatch_variant_record__hash_runs_on_user_record.silt b/tests/golden/lang/traits/vm_dispatch_variant_record__hash_runs_on_user_record.silt index 685868aa8..efd32ed6d 100644 --- a/tests/golden/lang/traits/vm_dispatch_variant_record__hash_runs_on_user_record.silt +++ b/tests/golden/lang/traits/vm_dispatch_variant_record__hash_runs_on_user_record.silt @@ -1,5 +1,5 @@ type Point { x: Int, y: Int, } -fn h(a: a) -> Int where a: Hash { a.hash() } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } fn main() { let p = Point { x: 1, y: 2 } println(h(p)) diff --git a/tests/golden/lang/typecheck/numeric_defaulting__compare_constrained_fn_at_int.silt b/tests/golden/lang/typecheck/numeric_defaulting__compare_constrained_fn_at_int.silt index c0d6c9852..a2e9c603d 100644 --- a/tests/golden/lang/typecheck/numeric_defaulting__compare_constrained_fn_at_int.silt +++ b/tests/golden/lang/typecheck/numeric_defaulting__compare_constrained_fn_at_int.silt @@ -2,7 +2,7 @@ -- exit: 0 -- stderr-not-contains: error fn pick(a: a, b: a) -> a where a: Compare { - match a.compare(b) { + match Compare.compare(a, b) { 1 -> a _ -> b } diff --git a/tests/golden/lang/typecheck/numeric_defaulting__compare_constrained_fn_at_string.silt b/tests/golden/lang/typecheck/numeric_defaulting__compare_constrained_fn_at_string.silt index f2687c5fe..fad77a784 100644 --- a/tests/golden/lang/typecheck/numeric_defaulting__compare_constrained_fn_at_string.silt +++ b/tests/golden/lang/typecheck/numeric_defaulting__compare_constrained_fn_at_string.silt @@ -2,7 +2,7 @@ -- exit: 0 -- stderr-not-contains: error fn pick(a: a, b: a) -> a where a: Compare { - match a.compare(b) { + match Compare.compare(a, b) { 1 -> a _ -> b } diff --git a/tests/golden/lang/values/a_deep_value_has_a_key.silt b/tests/golden/lang/values/a_deep_value_has_a_key.silt index 54da07763..7903d14c8 100644 --- a/tests/golden/lang/values/a_deep_value_has_a_key.silt +++ b/tests/golden/lang/values/a_deep_value_has_a_key.silt @@ -45,8 +45,8 @@ fn main() { println(a == c) println(a < c) println(c < a) - println(a.hash() == b.hash()) - println(a.hash() == c.hash()) + println(Hash.hash(a) == Hash.hash(b)) + println(Hash.hash(a) == Hash.hash(c)) println(set.length(set.from_list([a, b, c]))) let p = chain(50000, 0) @@ -55,6 +55,6 @@ fn main() { println(p == q) println(p == r) println(p < r) - println(p.hash() == q.hash()) + println(Hash.hash(p) == Hash.hash(q)) println(set.length(set.from_list([p, q, r]))) } diff --git a/tests/golden/lang/values/order_does_not_depend_on_other_imports/sa/src/lib.silt b/tests/golden/lang/values/order_does_not_depend_on_other_imports/sa/src/lib.silt index 4cf11005f..2f2768cdc 100644 --- a/tests/golden/lang/values/order_does_not_depend_on_other_imports/sa/src/lib.silt +++ b/tests/golden/lang/values/order_does_not_depend_on_other_imports/sa/src/lib.silt @@ -2,7 +2,7 @@ import list pub type ColorA { Red, Blue } pub fn report() -> String { let lt = Red < Blue - let cmp = Red.compare(Blue) + let cmp = Compare.compare(Red, Blue) let sorted = [Blue, Red] |> list.sort "Red < Blue = {lt}; Red.compare(Blue) = {cmp}; list.sort = {sorted}" } diff --git a/tests/golden/lang/values/program_ioerror_beside_builtin.silt b/tests/golden/lang/values/program_ioerror_beside_builtin.silt index 6095fba23..4374fecd1 100644 --- a/tests/golden/lang/values/program_ioerror_beside_builtin.silt +++ b/tests/golden/lang/values/program_ioerror_beside_builtin.silt @@ -20,14 +20,14 @@ trait Display for IoError { fn main() { let mine = Oops("x") - println(mine.message()) - println(mine.display()) + println(Error.message(mine)) + println("{mine}") println(mine) match io.read_file("does-not-exist.txt") { Ok(_) -> println("read") Err(e) -> { - println(e.message()) - println(e.display()) + println(Error.message(e)) + println("{e}") println(e) } } diff --git a/tests/golden/lang/values/same_named_enums_keep_their_impls/main.silt b/tests/golden/lang/values/same_named_enums_keep_their_impls/main.silt index 94cdbd4fa..9d23b079d 100644 --- a/tests/golden/lang/values/same_named_enums_keep_their_impls/main.silt +++ b/tests/golden/lang/values/same_named_enums_keep_their_impls/main.silt @@ -3,10 +3,10 @@ -- order (stage 5 verifier F1). import b import a -fn show(x: t) -> String where t: Display { x.display() } +fn show(x: t) -> String where t: Display { "{x}" } fn main() { - println(a.mk().display()) - println(b.mk().display()) + println("{a.mk()}") + println("{b.mk()}") println(show(a.mk())) println(show(b.mk())) } diff --git a/tests/golden/lang/values/same_named_records_methods_by_type/main.silt b/tests/golden/lang/values/same_named_records_methods_by_type/main.silt index f13a1ff80..56bfd6f37 100644 --- a/tests/golden/lang/values/same_named_records_methods_by_type/main.silt +++ b/tests/golden/lang/values/same_named_records_methods_by_type/main.silt @@ -7,10 +7,10 @@ import b fn main() { let p = a.make(1) let q = b.make(2) - println(p.display()) - println(q.display()) - println(a.Pt.display(p)) - println(b.Pt.display(q)) - println(p.scale()) - println(q.scale()) + println("{p}") + println("{q}") + println("{p}") + println("{q}") + println(a.Scale.scale(p)) + println(b.Scale.scale(q)) } diff --git a/tests/golden/lang/values/shared_variant_name_one_module_enums.silt b/tests/golden/lang/values/shared_variant_name_one_module_enums.silt index 8a8382342..c81d53b27 100644 --- a/tests/golden/lang/values/shared_variant_name_one_module_enums.silt +++ b/tests/golden/lang/values/shared_variant_name_one_module_enums.silt @@ -4,9 +4,9 @@ type Shape { Circle(Int), Sq } trait Display for Shape { fn display(self) -> String { "A-shape" } } type Form { Circle(Int), Tri(Int) } trait Display for Form { fn display(self) -> String { "B-form" } } -fn show(x: t) -> String where t: Display { x.display() } +fn show(x: t) -> String where t: Display { "{x}" } fn main() { - println(Shape.Circle(1).display()) - println(Form.Circle(1).display()) + println("{Shape.Circle(1)}") + println("{Form.Circle(1)}") println(show(Shape.Circle(1))) } diff --git a/tests/golden/lang/values/shared_variant_name_two_module_enums/main.silt b/tests/golden/lang/values/shared_variant_name_two_module_enums/main.silt index fd92eec01..6e199e8a8 100644 --- a/tests/golden/lang/values/shared_variant_name_two_module_enums/main.silt +++ b/tests/golden/lang/values/shared_variant_name_two_module_enums/main.silt @@ -2,10 +2,10 @@ -- value runs its own type's impls (F1). import a import b -fn show(x: t) -> String where t: Display { x.display() } +fn show(x: t) -> String where t: Display { "{x}" } fn main() { - println(a.mk().display()) - println(b.mk().display()) + println("{a.mk()}") + println("{b.mk()}") println(show(a.mk())) println(show(b.mk())) println(a.mk() == a.mk()) diff --git a/tests/golden/lang/values/the_hash_of_a_variant_holds_nothing_of_its_type.silt b/tests/golden/lang/values/the_hash_of_a_variant_holds_nothing_of_its_type.silt index 084a50a18..57fe3d895 100644 --- a/tests/golden/lang/values/the_hash_of_a_variant_holds_nothing_of_its_type.silt +++ b/tests/golden/lang/values/the_hash_of_a_variant_holds_nothing_of_its_type.silt @@ -19,11 +19,11 @@ type There { } fn main() { - println(Dot.hash() == Point.hash()) - println(Box(3, 4).hash() == Rect(3, 4).hash()) - println([Box(3, 4), Dot].hash() == [Rect(3, 4), Point].hash()) + println(Hash.hash(Dot) == Hash.hash(Point)) + println(Hash.hash(Box(3, 4)) == Hash.hash(Rect(3, 4))) + println(Hash.hash([Box(3, 4), Dot]) == Hash.hash([Rect(3, 4), Point])) -- Which variant it is, and its fields, are in the hash. - println(Dot.hash() == Box(0, 0).hash()) - println(Box(3, 4).hash() == Box(4, 3).hash()) - println(Between { v: 1 }.hash() == Between { v: 1 }.hash()) + println(Hash.hash(Dot) == Hash.hash(Box(0, 0))) + println(Hash.hash(Box(3, 4)) == Hash.hash(Box(4, 3))) + println(Hash.hash(Between { v: 1 }) == Hash.hash(Between { v: 1 })) } diff --git a/tests/golden/lang/values/two_modules_same_variant_names/main.silt b/tests/golden/lang/values/two_modules_same_variant_names/main.silt index 145566387..8e86a812a 100644 --- a/tests/golden/lang/values/two_modules_same_variant_names/main.silt +++ b/tests/golden/lang/values/two_modules_same_variant_names/main.silt @@ -12,7 +12,7 @@ fn main() { println("a: Red < Blue = {a.red_lt_blue()}, sorted {a.sorted()}, distinct {a.distinct()}") println("b: Blue < Red = {b.blue_lt_red()}, sorted {b.sorted()}, distinct {b.distinct()}") println("a.red() < a.blue() = {a.red() < a.blue()}; b.red() < b.blue() = {b.red() < b.blue()}") - println("a compare: {a.red().compare(a.blue())}; b compare: {b.red().compare(b.blue())}") + println("a compare: {Compare.compare(a.red(), a.blue())}; b compare: {Compare.compare(b.red(), b.blue())}") let ma = map.from_entries([(a.blue(), "blue"), (a.red(), "red")]) let mb = map.from_entries([(b.blue(), "blue"), (b.red(), "red")]) println("a keys: {map.keys(ma)}; b keys: {map.keys(mb)}") diff --git a/tests/golden/lang/values/two_packages_same_module_type_names/da/src/lib.silt b/tests/golden/lang/values/two_packages_same_module_type_names/da/src/lib.silt index c0fe83b0c..359815182 100644 --- a/tests/golden/lang/values/two_packages_same_module_type_names/da/src/lib.silt +++ b/tests/golden/lang/values/two_packages_same_module_type_names/da/src/lib.silt @@ -1,5 +1,5 @@ import util pub fn mk() -> util.Pt { util.Pt { x: 1 } } -pub fn show() -> String { mk().display() } +pub fn show() -> String { "{mk()}" } pub fn reds() -> List(util.Color) { [util.Green, util.Red] } pub fn raw() -> util.Raw { util.Raw { v: 1 } } diff --git a/tests/golden/lang/values/two_packages_same_module_type_names/db/src/lib.silt b/tests/golden/lang/values/two_packages_same_module_type_names/db/src/lib.silt index c0fe83b0c..359815182 100644 --- a/tests/golden/lang/values/two_packages_same_module_type_names/db/src/lib.silt +++ b/tests/golden/lang/values/two_packages_same_module_type_names/db/src/lib.silt @@ -1,5 +1,5 @@ import util pub fn mk() -> util.Pt { util.Pt { x: 1 } } -pub fn show() -> String { mk().display() } +pub fn show() -> String { "{mk()}" } pub fn reds() -> List(util.Color) { [util.Green, util.Red] } pub fn raw() -> util.Raw { util.Raw { v: 1 } } diff --git a/tests/golden/lang/vm/returns__every_kind_from_every_shape_of_call.silt b/tests/golden/lang/vm/returns__every_kind_from_every_shape_of_call.silt index 2260151ba..a1bb7b60f 100644 --- a/tests/golden/lang/vm/returns__every_kind_from_every_shape_of_call.silt +++ b/tests/golden/lang/vm/returns__every_kind_from_every_shape_of_call.silt @@ -103,31 +103,31 @@ trait Kinds { fn variant(self) -> Shape fn closure(self) -> Fn(Int) -> Int fn default_int(self) -> Int { - self.int() + Kinds.int(self) } fn default_float(self) -> Float { - self.float() + Kinds.float(self) } fn default_bool(self) -> Bool { - self.bool() + Kinds.bool(self) } fn default_unit(self) -> () { - self.unit() + Kinds.unit(self) } fn default_string(self) -> String { - self.string() + Kinds.string(self) } fn default_list(self) -> List(Int) { - self.list() + Kinds.list(self) } fn default_record(self) -> Point { - self.record() + Kinds.record(self) } fn default_variant(self) -> Shape { - self.variant() + Kinds.variant(self) } fn default_closure(self) -> Fn(Int) -> Int { - self.closure() + Kinds.closure(self) } } @@ -241,24 +241,24 @@ fn main() { println("a method and a default method") let p = Point { x: 1, y: 2 } - println(p.int()) - println(p.float()) - println(p.bool()) - println(p.unit()) - println(p.string()) - println(p.list()) - println(p.record()) - println(p.variant()) - println(p.closure()(2)) - println(p.default_int()) - println(p.default_float()) - println(p.default_bool()) - println(p.default_unit()) - println(p.default_string()) - println(p.default_list()) - println(p.default_record()) - println(p.default_variant()) - println(p.default_closure()(2)) + println(Kinds.int(p)) + println(Kinds.float(p)) + println(Kinds.bool(p)) + println(Kinds.unit(p)) + println(Kinds.string(p)) + println(Kinds.list(p)) + println(Kinds.record(p)) + println(Kinds.variant(p)) + println(Kinds.closure(p)(2)) + println(Kinds.default_int(p)) + println(Kinds.default_float(p)) + println(Kinds.default_bool(p)) + println(Kinds.default_unit(p)) + println(Kinds.default_string(p)) + println(Kinds.default_list(p)) + println(Kinds.default_record(p)) + println(Kinds.default_variant(p)) + println(Kinds.default_closure(p)(2)) println("a function a builtin calls back") println(list.map([1, 2]) { x -> x + 6 }) diff --git a/tests/golden/lang/vm/round87_vm_method_builtinfn_pure__error_message_in_task.silt b/tests/golden/lang/vm/round87_vm_method_builtinfn_pure__error_message_in_task.silt index fa93362e1..164d70c22 100644 --- a/tests/golden/lang/vm/round87_vm_method_builtinfn_pure__error_message_in_task.silt +++ b/tests/golden/lang/vm/round87_vm_method_builtinfn_pure__error_message_in_task.silt @@ -10,12 +10,12 @@ fn main() { let h = task.spawn({ -> let a = match int.parse("x") { Ok(_) -> "ok" - Err(e) -> e.message() + Err(e) -> Error.message(e) } channel.send(ch, a) let b = match io.read_file("round87_missing_file.txt") { Ok(_) -> "ok" - Err(e) -> e.message() + Err(e) -> Error.message(e) } "{a} | {b}" }) diff --git a/tests/golden/lsp/hover_on_a_trait/case.stdout b/tests/golden/lsp/hover_on_a_trait/case.stdout index e5d5a272e..9e9fdd697 100644 --- a/tests/golden/lsp/hover_on_a_trait/case.stdout +++ b/tests/golden/lsp/hover_on_a_trait/case.stdout @@ -79,8 +79,8 @@ trait Display { --- -How a value is shown: `println`, `print`, interpolation, `.display()` -and `string.from` show it so. A type has it by its structure, or by an +How a value is shown: `println`, `print`, interpolation and +`string.from` show it so. A type has it by its structure, or by an impl written in the module that declares the type. > hover 41:76 ```silt @@ -134,8 +134,8 @@ trait Display { --- -How a value is shown: `println`, `print`, interpolation, `.display()` -and `string.from` show it so. A type has it by its structure, or by an +How a value is shown: `println`, `print`, interpolation and +`string.from` show it so. A type has it by its structure, or by an impl written in the module that declares the type. > hover 76:13 ```silt @@ -357,26 +357,29 @@ fn main() { written, else as `json.decode(value, T)` does. For a `type a` with the bound, `a.decode(value)`. It takes no value of the type: `x.decode(..)` on a value is no call of it. -> hover 86:25 +> hover 86:18 ```silt -Fn(Box) -> Int +fn size(self) -> Int ``` - ---- - -Says how big. -> hover 87:14 +> hover 87:18 ```silt -Fn(Box) -> Int +fn size(self) -> Int ``` -> hover 88:17 +> hover 88:18 ```silt -Fn(Box) -> Int +fn size(self) -> Int ``` -> hover 89:25 +> hover 86:12 ```silt -Fn(Box) -> String +trait Sized { + fn size(self) -> Int + fn twice(self) -> Int +} ``` + +--- + +Says how big. > definition 41:76 shapes.silt:2:11-2:15 > definition 41:85 diff --git a/tests/golden/lsp/hover_on_a_trait/main.silt b/tests/golden/lsp/hover_on_a_trait/main.silt index dd62532c7..c12cb8726 100644 --- a/tests/golden/lsp/hover_on_a_trait/main.silt +++ b/tests/golden/lsp/hover_on_a_trait/main.silt @@ -11,10 +11,10 @@ -- lsp: hover 51:8 -- lsp: hover 58:8 -- lsp: hover 35:35 --- lsp: hover 86:25 --- lsp: hover 87:14 --- lsp: hover 88:17 --- lsp: hover 89:25 +-- lsp: hover 86:18 +-- lsp: hover 87:18 +-- lsp: hover 88:18 +-- lsp: hover 86:12 -- lsp: definition 41:76 -- lsp: definition 41:85 -- lsp: definition 68:8 @@ -26,9 +26,9 @@ -- it), in an impl's header, as a supertrait, at its declaration. A -- method's signature written on several lines keeps its lines. -- Definition goes to a program trait's declaration; one of silt's own --- has no file. A method's name at a call is the method, not its trait --- (on a record literal, a binding, a call's value), and a builtin --- module's trait is written as a program names it (`json.Value`). +-- has no file. A method's name at a call through its trait is the method +-- (of a record literal, a binding, a call's value), the trait's name the +-- trait; a builtin module's trait is written as a program names it. import json import shapes @@ -45,7 +45,7 @@ fn show(x: a, y: b, z: c, w: d) where a: json.Encode + Display, b: shapes.Area, -- Says how big. trait Sized { fn size(self) -> Int - fn twice(self) -> Int { self.size() * 2 } + fn twice(self) -> Int { Sized.size(self) * 2 } } trait Big: Sized { @@ -83,8 +83,8 @@ fn mk() -> Box { fn main() { let b = Box { w: 1 } - println(Box { w: 1 }.size()) - println(b.size()) - println(mk().size()) - println(Box { w: 1 }.display()) + println(Sized.size(Box { w: 1 })) + println(Sized.size(b)) + println(Sized.size(mk())) + println("{Box { w: 1 }}") } diff --git a/tests/golden/lsp/hover_on_an_imported_item/case.stdout b/tests/golden/lsp/hover_on_an_imported_item/case.stdout index 3112a99e8..c068d91d0 100644 --- a/tests/golden/lsp/hover_on_an_imported_item/case.stdout +++ b/tests/golden/lsp/hover_on_an_imported_item/case.stdout @@ -88,7 +88,7 @@ fn main() { let input = """{"name": "Alice", "age": 30}""" match json.parse(input, User) { Ok(user) -> println(user.name) - Err(e) -> println("Error: {e.message()}") + Err(e) -> println("Error: {Error.message(e)}") } } ``` diff --git a/tests/golden/lsp/json_decode_completion_on_a_value.silt b/tests/golden/lsp/json_decode_completion_on_a_value.silt index 80fdddebf..8d9469a5c 100644 --- a/tests/golden/lsp/json_decode_completion_on_a_value.silt +++ b/tests/golden/lsp/json_decode_completion_on_a_value.silt @@ -1,7 +1,9 @@ -- cmd: lsp --- lsp: completion 13:14 --- `decode` takes no value of the type: completion after a dot on a value --- does not offer it, also where json is imported (`display` it does). +-- lsp: completion 15:14 +-- lsp: completion 16:23 +-- After a dot on a value completion offers its fields, no method of any +-- trait; after `json.Decode.` nothing: `decode` takes no value of the +-- type, so it is called through the type (`Money.decode`). import json type Money { @@ -10,6 +12,6 @@ type Money { fn main() { let m = Money { cents: 5 } - println(m.d) - println(json.stringify(m)) + println(m.c) + println(json.Decode.d) } diff --git a/tests/golden/lsp/json_decode_completion_on_a_value.stdout b/tests/golden/lsp/json_decode_completion_on_a_value.stdout index e3a3f74f1..e00cc713b 100644 --- a/tests/golden/lsp/json_decode_completion_on_a_value.stdout +++ b/tests/golden/lsp/json_decode_completion_on_a_value.stdout @@ -1,3 +1,6 @@ -13:11 error unknown field or method 'd' on type Money -> completion 13:14 -display +15:11 error type 'Money' has no field 'c' +16:11 error trait 'json.Decode' has no method 'd' +> completion 15:14 +cents +> completion 16:23 +(nothing) diff --git a/tests/golden/lsp/json_encode_completion_without_the_import.silt b/tests/golden/lsp/json_encode_completion_without_the_import.silt deleted file mode 100644 index b403c8a36..000000000 --- a/tests/golden/lsp/json_encode_completion_without_the_import.silt +++ /dev/null @@ -1,15 +0,0 @@ --- cmd: lsp --- lsp: completion 13:16 --- lsp: completion 14:14 --- Without `import json` no value has the method `encode`: completion --- after a dot does not offer it (`display` it does). -type Money { - cents: Int, -} - -fn main() { - let m = Money { cents: 5 } - println(m.cents) - println(m.enc) - println(m.d) -} diff --git a/tests/golden/lsp/json_encode_completion_without_the_import.stdout b/tests/golden/lsp/json_encode_completion_without_the_import.stdout deleted file mode 100644 index 1515c2499..000000000 --- a/tests/golden/lsp/json_encode_completion_without_the_import.stdout +++ /dev/null @@ -1,6 +0,0 @@ -13:11 error unknown field or method 'enc' on type Money -14:11 error unknown field or method 'd' on type Money -> completion 13:16 -(nothing) -> completion 14:14 -display diff --git a/tests/golden/lsp/json_encode_in_the_editor.silt b/tests/golden/lsp/json_encode_in_the_editor.silt index 66d4e4605..79927aa78 100644 --- a/tests/golden/lsp/json_encode_in_the_editor.silt +++ b/tests/golden/lsp/json_encode_in_the_editor.silt @@ -1,12 +1,12 @@ -- cmd: lsp -- lsp: hover 16:39 -- lsp: hover 17:8 --- lsp: hover 22:13 --- lsp: completion 23:16 +-- lsp: hover 22:25 +-- lsp: completion 23:26 -- lsp: definition 16:39 -- The editor knows `json.Encode`: a hover on it in a `where` clause, on --- `json.stringify` and on a value's `.encode()`, the method among those --- offered after a dot, and no definition in a file (it is json's). +-- `json.stringify` and on `json.Encode.encode`, the method offered after +-- `json.Encode.`, and no definition in a file (it is json's). import json type Money { @@ -19,7 +19,7 @@ fn send(x: a) -> String where a: json.Encode { fn main() { let m = Money { cents: 5 } - println(m.encode()) - println(m.enc) + println(json.Encode.encode(m)) + println(json.Encode.enc) println(send(m)) } diff --git a/tests/golden/lsp/json_encode_in_the_editor.stdout b/tests/golden/lsp/json_encode_in_the_editor.stdout index c0b5eabd3..7ff5c5dd9 100644 --- a/tests/golden/lsp/json_encode_in_the_editor.stdout +++ b/tests/golden/lsp/json_encode_in_the_editor.stdout @@ -1,4 +1,4 @@ -23:11 error unknown field or method 'enc' on type Money +23:11 error trait 'json.Encode' has no method 'enc' > hover 16:39 ```silt trait json.Encode { @@ -131,11 +131,11 @@ fn main() { -- "2026-10-19" } ``` -> hover 22:13 +> hover 22:25 ```silt -Fn(Money) -> Value +fn encode(self) -> json.Value ``` -> completion 23:16 +> completion 23:26 encode > definition 16:39 (nothing) diff --git a/tests/golden/lsp/locals_by_binding.silt b/tests/golden/lsp/locals_by_binding.silt index c6b87d756..451ff3ebc 100644 --- a/tests/golden/lsp/locals_by_binding.silt +++ b/tests/golden/lsp/locals_by_binding.silt @@ -3,7 +3,7 @@ -- lsp: references 22:7 -- lsp: definition 23:3 -- lsp: rename 27:13 first --- lsp: references 33:19 +-- lsp: references 33:24 -- lsp: references 40:21 -- lsp: definition 41:26 -- lsp: references 46:22 @@ -30,7 +30,7 @@ fn pair((a, b): (Int, Int), P { x, y }) { trait Scale { fn scale(self, by: Int) -> Int { - self.size() * by + Scale.size(self) * by } fn size(self) -> Int } diff --git a/tests/golden/lsp/locals_by_binding.stdout b/tests/golden/lsp/locals_by_binding.stdout index ed69f0bb7..81822e410 100644 --- a/tests/golden/lsp/locals_by_binding.stdout +++ b/tests/golden/lsp/locals_by_binding.stdout @@ -10,9 +10,9 @@ locals_by_binding.silt:22:7-22:8 locals_by_binding.silt:26:10-26:11 => first locals_by_binding.silt:27:13-27:14 => first locals_by_binding.silt:28:17-28:18 => first -> references 33:19 +> references 33:24 locals_by_binding.silt:32:18-32:20 -locals_by_binding.silt:33:19-33:21 +locals_by_binding.silt:33:24-33:26 > references 40:21 locals_by_binding.silt:40:9-40:10 locals_by_binding.silt:40:21-40:22 diff --git a/tests/golden/lsp/rename_by_meaning.silt b/tests/golden/lsp/rename_by_meaning.silt index 9a949bb16..30b1d4ad4 100644 --- a/tests/golden/lsp/rename_by_meaning.silt +++ b/tests/golden/lsp/rename_by_meaning.silt @@ -1,9 +1,9 @@ -- cmd: lsp -- lsp: rename 33:7 Sizable --- lsp: rename 52:5 resize --- lsp: definition 52:5 --- lsp: definition 52:18 --- lsp: definition 100:88 +-- lsp: rename 52:10 resize +-- lsp: definition 52:10 +-- lsp: definition 52:30 +-- lsp: definition 100:93 -- lsp: rename 34:12 me -- lsp: rename 56:13 width -- lsp: rename 57:3 width @@ -32,7 +32,7 @@ type Box { trait Sized { fn scale(self, by: Int) -> Int { - self.size() * by + Sized.size(self) * by } fn size(self) -> Int } @@ -49,7 +49,7 @@ type Side { } fn twice(x: a) -> Int where a: Sized { - x.scale(2) + x.size() + Sized.scale(x, 2) + Sized.size(x) } fn unbox(b: Box) -> Int { @@ -92,10 +92,10 @@ trait Container { } fn head(c: t) -> ::Item where t: Container { - c.first() + Container.first(c) } fn main() { let b = Box { w: 3 } - println(twice(b) + unbox(b) + either(Left(1)) + scopes(1) + blocks(1) + loops(1) + b.size()) + println(twice(b) + unbox(b) + either(Left(1)) + scopes(1) + blocks(1) + loops(1) + Sized.size(b)) } diff --git a/tests/golden/lsp/rename_by_meaning.stdout b/tests/golden/lsp/rename_by_meaning.stdout index 16e2cfda1..78bcb2fa8 100644 --- a/tests/golden/lsp/rename_by_meaning.stdout +++ b/tests/golden/lsp/rename_by_meaning.stdout @@ -1,14 +1,18 @@ > rename 33:7 Sizable rename_by_meaning.silt:33:7-33:12 => Sizable +rename_by_meaning.silt:35:5-35:10 => Sizable rename_by_meaning.silt:40:7-40:12 => Sizable rename_by_meaning.silt:51:32-51:37 => Sizable -> rename 52:5 resize +rename_by_meaning.silt:52:3-52:8 => Sizable +rename_by_meaning.silt:52:23-52:28 => Sizable +rename_by_meaning.silt:100:86-100:91 => Sizable +> rename 52:10 resize (nothing) -> definition 52:5 +> definition 52:10 rename_by_meaning.silt:34:6-34:11 -> definition 52:18 +> definition 52:30 rename_by_meaning.silt:37:6-37:10 -> definition 100:88 +> definition 100:93 rename_by_meaning.silt:41:6-41:10 > rename 34:12 me error: `self` is the receiver of a method and cannot be renamed: a method's first parameter is `self` @@ -57,3 +61,4 @@ rename_by_meaning.silt:81:25-81:26 rename_by_meaning.silt:89:7-89:16 => Holder rename_by_meaning.silt:94:24-94:33 => Holder rename_by_meaning.silt:94:50-94:59 => Holder +rename_by_meaning.silt:95:3-95:12 => Holder diff --git a/tests/golden/lsp/trait_call_in_the_editor/case.stdout b/tests/golden/lsp/trait_call_in_the_editor/case.stdout new file mode 100644 index 000000000..8d2f19af7 --- /dev/null +++ b/tests/golden/lsp/trait_call_in_the_editor/case.stdout @@ -0,0 +1,41 @@ +23:11 error trait 'shapes.Area' has no method 'ar' +24:11 error trait 'Display' has no method 'dis' +25:11 error trait 'Greet' has no method 'gr' +> completion 23:23 +area +scaled +> completion 24:20 +(nothing) +> completion 25:18 +greet +> hover 26:24 +```silt +fn area(self) -> Int +``` + +--- + +The area, in square units. +> hover 26:19 +```silt +pub trait Area { + fn area(self) -> Int + fn scaled(self, by: Int) -> Int +} +``` + +--- + +A shape's area. +> signature 27:33 +fn scaled(self, by: Int) -> Int +argument 2: by: Int +> definition 26:24 +shapes.silt:11:6-11:10 +> definition 28:18 +main.silt:20:26-20:31 +> references 28:12 +main.silt:19:7-19:12 +main.silt:20:7-20:12 +main.silt:25:11-25:16 +main.silt:28:11-28:16 diff --git a/tests/golden/lsp/trait_call_in_the_editor/main.silt b/tests/golden/lsp/trait_call_in_the_editor/main.silt new file mode 100644 index 000000000..1e0433e63 --- /dev/null +++ b/tests/golden/lsp/trait_call_in_the_editor/main.silt @@ -0,0 +1,29 @@ +-- cmd: lsp +-- lsp: completion 23:23 +-- lsp: completion 24:20 +-- lsp: completion 25:18 +-- lsp: hover 26:24 +-- lsp: hover 26:19 +-- lsp: signature 27:33 +-- lsp: definition 26:24 +-- lsp: definition 28:18 +-- lsp: references 28:12 +-- The editor knows a call through a trait: after `Trait.` it offers the +-- methods the trait is called with (not `Display`'s); hover on the +-- method shows it as the trait declares it, on the trait the trait; +-- signature help counts the argument of type Self; definition goes to +-- the method of the impl, or the trait's; references find the trait's +-- name at its calls. +import shapes +import shapes.{ Square } +trait Greet { fn greet(self) -> String } +trait Greet for Int { fn greet(self) -> String { "hi" } } +fn main() { + let s = Square { side: 2 } + println(shapes.Area.ar) + println(Display.dis) + println(Greet.gr) + println(shapes.Area.area(s)) + println(shapes.Area.scaled(s, 3)) + println(Greet.greet(5)) +} diff --git a/tests/golden/lsp/trait_call_in_the_editor/shapes.silt b/tests/golden/lsp/trait_call_in_the_editor/shapes.silt new file mode 100644 index 000000000..7bcb3d458 --- /dev/null +++ b/tests/golden/lsp/trait_call_in_the_editor/shapes.silt @@ -0,0 +1,13 @@ +pub type Square { side: Int } + +-- A shape's area. +pub trait Area { + -- The area, in square units. + fn area(self) -> Int + fn scaled(self, by: Int) -> Int +} + +trait Area for Square { + fn area(self) -> Int { self.side * self.side } + fn scaled(self, by: Int) -> Int { self.side * by } +} diff --git a/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__assoc_type_basic_snippet_runs.silt b/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__assoc_type_basic_snippet_runs.silt index 0a7d783ea..4823d5ef2 100644 --- a/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__assoc_type_basic_snippet_runs.silt +++ b/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__assoc_type_basic_snippet_runs.silt @@ -15,5 +15,5 @@ trait Stream for Wrap { fn main() { let w = Wrap { v: 7 } - println(w.first()) + println(Stream.first(w)) } diff --git a/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__bound_on_assoc_type_snippet_typechecks.silt b/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__bound_on_assoc_type_snippet_typechecks.silt index 04b4be269..afdfd2619 100644 --- a/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__bound_on_assoc_type_snippet_typechecks.silt +++ b/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__bound_on_assoc_type_snippet_typechecks.silt @@ -12,5 +12,5 @@ trait Container for Box { fn main() { let b = Box { v: 5 } - println(b.first()) + println(Container.first(b)) } diff --git a/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__multiple_assoc_types_snippet_runs.silt b/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__multiple_assoc_types_snippet_runs.silt index 6ee0db667..05842af4f 100644 --- a/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__multiple_assoc_types_snippet_runs.silt +++ b/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__multiple_assoc_types_snippet_runs.silt @@ -17,6 +17,6 @@ trait Pair for IntStringPair { fn main() { let p = IntStringPair { a: 13, b: "ok" } - println(p.first()) - println(p.second()) + println(Pair.first(p)) + println(Pair.second(p)) } diff --git a/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__qualified_projection_snippet_runs.silt b/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__qualified_projection_snippet_runs.silt index 2457479eb..5b39f2256 100644 --- a/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__qualified_projection_snippet_runs.silt +++ b/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__qualified_projection_snippet_runs.silt @@ -11,7 +11,7 @@ trait Producer for Wrap { } fn first_out(w: Wrap) -> ::Out { - w.produce() + Producer.produce(w) } fn main() { diff --git a/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__supertrait_assoc_inheritance_snippet_runs.silt b/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__supertrait_assoc_inheritance_snippet_runs.silt index d57feac23..1dd8adb86 100644 --- a/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__supertrait_assoc_inheritance_snippet_runs.silt +++ b/tests/golden/meta/assoc_types/docs_round68_assoc_types_and_rows_walker_tests__supertrait_assoc_inheritance_snippet_runs.silt @@ -20,5 +20,5 @@ trait Sub for Wrap { fn main() { let w = Wrap { v: 41 } - println(w.first()) + println(Sub.first(w)) } diff --git a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__barrage.silt b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__barrage.silt index fa65fd3e3..bdec174df 100644 --- a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__barrage.silt +++ b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__barrage.silt @@ -3,14 +3,14 @@ type Tagged { Foo(Int), Bar(Int, String), } type Point { x: Int, y: Int, } type Box(a) { Boxed(a), } type Wrapped(a) { value: a } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { println(cmp_gen(Red, Green)) println(cmp_gen(Foo(5), Foo(3))) println(eq_gen(Point { x: 1, y: 2 }, Point { x: 1, y: 2 })) println(cmp_gen(Boxed(1), Boxed(2))) println(d(Wrapped { value: 42 })) - println(Color.compare(Red, Green)) + println(Compare.compare(Red, Green)) } diff --git a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__barrage_extended_shapes.silt b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__barrage_extended_shapes.silt index 8c9da0e69..003d651b4 100644 --- a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__barrage_extended_shapes.silt +++ b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__barrage_extended_shapes.silt @@ -2,10 +2,10 @@ type Tree { Leaf, Node(Tree, Tree), } type GTree(a) { GLeaf, GNode(GTree(a), GTree(a)), } type Big { a: Int, b: Int, c: Int, d: String, } type Status { Active(Int), Pending, Done, Cancelled(String), Failed(Int, String), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { -- Shape 7: self-recursive enum println(cmp_gen(Leaf, Node(Leaf, Leaf))) diff --git a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__builtin_types.silt b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__builtin_types.silt index b3f5e1a13..392583156 100644 --- a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__builtin_types.silt +++ b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__builtin_types.silt @@ -2,10 +2,10 @@ -- the auto-derived traits as user types do. import time import http -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { println(cmp_gen(time.Monday, time.Friday)) println(eq_gen(time.Monday, time.Monday)) diff --git a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape1_nullary_enum.silt b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape1_nullary_enum.silt index 8e0fc14ee..9b4cfa9ed 100644 --- a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape1_nullary_enum.silt +++ b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape1_nullary_enum.silt @@ -1,15 +1,15 @@ -- The auto-derived Compare/Equal/Hash/Display of a nullary enum, -- through `where` bounds and qualified `Type.method` calls. type Color { Red, Green, Blue, } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { println(cmp_gen(Red, Green)) println(eq_gen(Red, Green)) let _ = h(Red) println(d(Red)) - println(Color.compare(Red, Green)) - println(Color.equal(Red, Green)) + println(Compare.compare(Red, Green)) + println(Red == Green) } diff --git a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape2_enum_with_args.silt b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape2_enum_with_args.silt index 8cb36859b..66c36ade5 100644 --- a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape2_enum_with_args.silt +++ b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape2_enum_with_args.silt @@ -1,8 +1,8 @@ type Tagged { Foo(Int), Bar(Int, String), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { println(cmp_gen(Foo(1), Foo(2))) println(eq_gen(Bar(1, "x"), Bar(1, "y"))) diff --git a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape3_record.silt b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape3_record.silt index b7f993c22..3990d63d7 100644 --- a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape3_record.silt +++ b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape3_record.silt @@ -1,16 +1,16 @@ type Point { x: Int, y: Int, } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { let p = Point { x: 1, y: 2 } let q = Point { x: 1, y: 3 } println(cmp_gen(p, q)) println(eq_gen(p, q)) - println(h(p) == p.hash()) + println(h(p) == Hash.hash(p)) println(d(p)) - println(p.compare(q)) - println(p.equal(q)) - println(p.display()) + println(Compare.compare(p, q)) + println(p == q) + println("{p}") } diff --git a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape4_generic_enum.silt b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape4_generic_enum.silt index 0565c23e2..47a31fe20 100644 --- a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape4_generic_enum.silt +++ b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape4_generic_enum.silt @@ -1,12 +1,12 @@ type Box(a) { Foo(a), Bar(a, a), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { println(cmp_gen(Foo(1), Foo(2))) println(eq_gen(Bar(1, 2), Bar(1, 3))) let _ = h(Foo(7)) println(d(Bar(1, 2))) - println(Box.compare(Foo(1), Foo(2))) + println(Compare.compare(Foo(1), Foo(2))) } diff --git a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape5_generic_enum_two_params.silt b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape5_generic_enum_two_params.silt index e10ce0445..f33cf0616 100644 --- a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape5_generic_enum_two_params.silt +++ b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape5_generic_enum_two_params.silt @@ -1,7 +1,7 @@ type Pair(a, b) { Tup(a, b), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } fn main() { println(cmp_gen(Tup(1, "a"), Tup(2, "b"))) println(eq_gen(Tup(1, "x"), Tup(1, "x"))) diff --git a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape6_generic_record.silt b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape6_generic_record.silt index 6ecd86879..f6ee68049 100644 --- a/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape6_generic_record.silt +++ b/tests/golden/meta/auto_derive/auto_derive_dead_arm_proof_tests__shape6_generic_record.silt @@ -1,8 +1,8 @@ type Wrapped(a) { value: a } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { let w = Wrapped { value: 5 } let v = Wrapped { value: 7 } @@ -10,6 +10,6 @@ fn main() { println(eq_gen(w, v)) let _ = h(w) println(d(w)) - println(w.compare(v)) - println(w.equal(v)) + println(Compare.compare(w, v)) + println(w == v) } diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_multi_variant_nullary_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_multi_variant_nullary_enum.silt index c0ba17934..f5a189c55 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_multi_variant_nullary_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_multi_variant_nullary_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Tri { A, B, C, } fn main() { println(cmp_gen(A, B)) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_multi_variant_payload_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_multi_variant_payload_enum.silt index 60cf3a942..14fbf7ee6 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_multi_variant_payload_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_multi_variant_payload_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Tagged { Foo(Int), Bar(Int, String), } fn main() { println(cmp_gen(Foo(1), Foo(2))) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_payload_variants_use_decl_order_ordinals_too.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_payload_variants_use_decl_order_ordinals_too.silt index 00a79d7a1..8c954999e 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_payload_variants_use_decl_order_ordinals_too.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_payload_variants_use_decl_order_ordinals_too.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Status { Pending, Active(Int), Done, } fn main() { println(cmp_gen(Pending, Active(99))) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_pins_decl_order_when_alphabet_disagrees.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_pins_decl_order_when_alphabet_disagrees.silt index a9582c135..a4e2ebb22 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_pins_decl_order_when_alphabet_disagrees.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_pins_decl_order_when_alphabet_disagrees.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type ZAM { Z, A, M, } fn main() { println(cmp_gen(Z, A)) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_pins_declaration_order_ordinals.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_pins_declaration_order_ordinals.silt index 1dd981b08..d2362f954 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_pins_declaration_order_ordinals.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_pins_declaration_order_ordinals.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Three { A, B, C, } fn main() { println(cmp_gen(A, B)) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_single_variant_nullary_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_single_variant_nullary_enum.silt index 544cd9879..eec295729 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_single_variant_nullary_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__compare_single_variant_nullary_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Solo { Only, } fn main() { println(cmp_gen(Only, Only)) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_multi_variant_nullary_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_multi_variant_nullary_enum.silt index 5217e011c..e55074755 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_multi_variant_nullary_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_multi_variant_nullary_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Tri { A, B, C, } fn main() { println(d(A)) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_multi_variant_payload_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_multi_variant_payload_enum.silt index 2e1274db8..59a0ca5b7 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_multi_variant_payload_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_multi_variant_payload_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Tagged { Foo(Int), Bar(Int, String), } fn main() { println(d(Foo(7))) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_single_variant_nullary_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_single_variant_nullary_enum.silt index e0238ab4c..ce80041a2 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_single_variant_nullary_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__display_single_variant_nullary_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Solo { Only, } fn main() { println(d(Only)) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_multi_variant_nullary_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_multi_variant_nullary_enum.silt index 6e8eae9d2..59cc634fc 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_multi_variant_nullary_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_multi_variant_nullary_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Tri { A, B, C, } fn main() { println(eq_gen(A, A)) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_multi_variant_payload_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_multi_variant_payload_enum.silt index 408a970c3..8c290644f 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_multi_variant_payload_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_multi_variant_payload_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Tagged { Foo(Int), Bar(Int, String), } fn main() { println(eq_gen(Foo(1), Foo(1))) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_single_variant_nullary_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_single_variant_nullary_enum.silt index cba3e3a1c..eb46c2d00 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_single_variant_nullary_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__equal_single_variant_nullary_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Solo { Only, } fn main() { println(eq_gen(Only, Only)) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__hash_multi_variant_payload_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__hash_multi_variant_payload_enum.silt index ed3e8a61c..126eb599a 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__hash_multi_variant_payload_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__hash_multi_variant_payload_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Tagged { Foo(Int), Bar(Int, String), } fn main() { let a = h(Foo(7)) diff --git a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__hash_single_variant_nullary_enum.silt b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__hash_single_variant_nullary_enum.silt index 04a4dde6c..40a9a9660 100644 --- a/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__hash_single_variant_nullary_enum.silt +++ b/tests/golden/meta/auto_derive/round69_auto_derive_scaffold_collapse_lock_tests__hash_single_variant_nullary_enum.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Solo { Only, } fn main() { let h1 = h(Only) diff --git a/tests/golden/meta/errors/round73_error_enum_registry_parity_tests__every_error_enum_message_dispatches.silt b/tests/golden/meta/errors/round73_error_enum_registry_parity_tests__every_error_enum_message_dispatches.silt index 75729dd9b..9542462eb 100644 --- a/tests/golden/meta/errors/round73_error_enum_registry_parity_tests__every_error_enum_message_dispatches.silt +++ b/tests/golden/meta/errors/round73_error_enum_registry_parity_tests__every_error_enum_message_dispatches.silt @@ -13,11 +13,11 @@ import time import bytes fn main() { - println(io.NotFound("missing.txt").message()) - println(json.MissingField("name").message()) - println(toml.MissingField("key").message()) - println(int.Empty.message()) - println(regex.TooBig.message()) - println(time.OutOfRange("month 13").message()) - println(bytes.InvalidHex("zz").message()) + println(Error.message(io.NotFound("missing.txt"))) + println(Error.message(json.MissingField("name"))) + println(Error.message(toml.MissingField("key"))) + println(Error.message(int.Empty)) + println(Error.message(regex.TooBig)) + println(Error.message(time.OutOfRange("month 13"))) + println(Error.message(bytes.InvalidHex("zz"))) } diff --git a/tests/golden/meta/errors/round73_error_enum_registry_parity_tests__the_http_and_tcp_error_enum_messages_dispatch.silt b/tests/golden/meta/errors/round73_error_enum_registry_parity_tests__the_http_and_tcp_error_enum_messages_dispatch.silt index 2f5b5859b..62a6726ea 100644 --- a/tests/golden/meta/errors/round73_error_enum_registry_parity_tests__the_http_and_tcp_error_enum_messages_dispatch.silt +++ b/tests/golden/meta/errors/round73_error_enum_registry_parity_tests__the_http_and_tcp_error_enum_messages_dispatch.silt @@ -8,6 +8,6 @@ import http import tcp fn main() { - println(http.Timeout.message()) - println(tcp.Closed.message()) + println(Error.message(http.Timeout)) + println(Error.message(tcp.Closed)) } diff --git a/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__list_unknown_method_names_bare_head.silt b/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__list_unknown_method_names_bare_head.silt deleted file mode 100644 index c3e404c49..000000000 --- a/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__list_unknown_method_names_bare_head.silt +++ /dev/null @@ -1,8 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown method 'qqqqqqqq_unrelated' on List --- stderr-not-contains: on type List -fn main() { - let xs = [1, 2, 3] - println(xs.qqqqqqqq_unrelated()) -} diff --git a/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__list_unknown_method_suggests_close_match.silt b/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__list_unknown_method_suggests_close_match.silt deleted file mode 100644 index 27fa1c87d..000000000 --- a/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__list_unknown_method_suggests_close_match.silt +++ /dev/null @@ -1,8 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown method --- stderr-contains: help: did you mean `display`? -fn main() { - let xs = [1, 2, 3] - println(xs.dispaly()) -} diff --git a/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__map_unknown_method_names_bare_head.silt b/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__map_unknown_method_names_bare_head.silt deleted file mode 100644 index 78919d0c9..000000000 --- a/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__map_unknown_method_names_bare_head.silt +++ /dev/null @@ -1,8 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown method 'qqqqqqqq_unrelated' on Map --- stderr-not-contains: on type Map -fn main() { - let m = #{ "a": 1, "b": 2 } - println(m.qqqqqqqq_unrelated()) -} diff --git a/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__set_unknown_method_names_bare_head.silt b/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__set_unknown_method_names_bare_head.silt deleted file mode 100644 index bee146fab..000000000 --- a/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__set_unknown_method_names_bare_head.silt +++ /dev/null @@ -1,8 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown method 'qqqqqqqq_unrelated' on Set --- stderr-not-contains: on type Set -fn main() { - let s = #[1, 2, 3] - println(s.qqqqqqqq_unrelated()) -} diff --git a/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__tuple_unknown_method_names_bare_head.silt b/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__tuple_unknown_method_names_bare_head.silt deleted file mode 100644 index 58290e516..000000000 --- a/tests/golden/meta/errors/round77_container_method_arms_collapse_tests__tuple_unknown_method_names_bare_head.silt +++ /dev/null @@ -1,8 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown method 'qqqqqqqq_unrelated' on Tuple --- stderr-not-contains: on type Tuple -fn main() { - let t = (1, 2) - println(t.qqqqqqqq_unrelated()) -} diff --git a/tests/golden/meta/generics/generics_doc_examples__trait_default_method_show.silt b/tests/golden/meta/generics/generics_doc_examples__trait_default_method_show.silt index a06da5c2a..42e5118fa 100644 --- a/tests/golden/meta/generics/generics_doc_examples__trait_default_method_show.silt +++ b/tests/golden/meta/generics/generics_doc_examples__trait_default_method_show.silt @@ -10,6 +10,6 @@ trait Show for Item { } fn main() { - println(Item { v: 1 }.show()) - println(Item { v: 1 }.debug()) + println(Show.show(Item { v: 1 })) + println(Show.debug(Item { v: 1 })) } diff --git a/tests/golden/meta/generics/generics_doc_examples__trait_show_override.silt b/tests/golden/meta/generics/generics_doc_examples__trait_show_override.silt index 332f2e0c9..cafdeeafa 100644 --- a/tests/golden/meta/generics/generics_doc_examples__trait_show_override.silt +++ b/tests/golden/meta/generics/generics_doc_examples__trait_show_override.silt @@ -11,6 +11,6 @@ trait Show for Item { } fn main() { - println(Item { v: 1 }.show()) - println(Item { v: 1 }.debug()) + println(Show.show(Item { v: 1 })) + println(Show.debug(Item { v: 1 })) } diff --git a/tests/golden/meta/generics/generics_doc_examples__value_receiver_on_no_self_rejected.silt b/tests/golden/meta/generics/generics_doc_examples__value_receiver_on_no_self_rejected.silt index d3fde0fbe..d66199901 100644 --- a/tests/golden/meta/generics/generics_doc_examples__value_receiver_on_no_self_rejected.silt +++ b/tests/golden/meta/generics/generics_doc_examples__value_receiver_on_no_self_rejected.silt @@ -1,7 +1,8 @@ -- cmd: check -- exit: 1 -- stderr-contains: error[type] --- stderr-contains: takes no `self` +-- stderr-contains: type 'Int' has no field 'default' +-- stderr-contains: call it on the type, `Int.default()` trait Default { fn default() -> Self } diff --git a/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_builtin_trait_for_local_type/main.silt b/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_builtin_trait_for_local_type/main.silt index 7607e57e7..e6d69ed65 100644 --- a/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_builtin_trait_for_local_type/main.silt +++ b/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_builtin_trait_for_local_type/main.silt @@ -8,5 +8,5 @@ trait Display for Color { fn main() { let c: Color = Red - println(c.display()) + println("{c}") } diff --git a/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_local_trait_for_builtin_type/main.silt b/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_local_trait_for_builtin_type/main.silt index 9bd533b46..54211032b 100644 --- a/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_local_trait_for_builtin_type/main.silt +++ b/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_local_trait_for_builtin_type/main.silt @@ -7,5 +7,5 @@ trait Greet for List(a) { fn main() { let xs = [1, 2, 3] - println(xs.greet()) + println(Greet.greet(xs)) } diff --git a/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_local_trait_for_local_type/main.silt b/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_local_trait_for_local_type/main.silt index fbd545c61..79fb235f0 100644 --- a/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_local_trait_for_local_type/main.silt +++ b/tests/golden/meta/traits/docs_round68_traits_doc_tests__impl_place_local_trait_for_local_type/main.silt @@ -7,5 +7,5 @@ trait Greet for Color { fn main() { let c: Color = Red - println(c.greet()) + println(Greet.greet(c)) } diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_nested_record_recurses_through_field_compare.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_nested_record_recurses_through_field_compare.silt index 2b15fd4c7..b58976f0d 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_nested_record_recurses_through_field_compare.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_nested_record_recurses_through_field_compare.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Inner { x: Int } type Wrap { r: Inner, tag: Int } fn main() { diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_one_field_record.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_one_field_record.silt index 4ba55ff57..04fa2e8b0 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_one_field_record.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_one_field_record.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type One { x: Int } fn main() { let a = One { x: 1 } diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_pins_field_declaration_order.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_pins_field_declaration_order.silt index 3651b9196..48be93899 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_pins_field_declaration_order.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_pins_field_declaration_order.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type R { z: Int, a: Int, m: Int } fn main() { println(cmp_gen(R { z: 1, a: 9, m: 9 }, R { z: 2, a: 0, m: 0 })) diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_three_field_record_lex_order.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_three_field_record_lex_order.silt index 2b5cd4c31..b07954bd8 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_three_field_record_lex_order.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__compare_three_field_record_lex_order.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type R { a: Int, b: Int, c: Int } fn main() { println(cmp_gen(R { a: 1, b: 0, c: 0 }, R { a: 2, b: 0, c: 0 })) diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_nested_record.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_nested_record.silt index 489d00b78..020bf45f3 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_nested_record.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_nested_record.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Inner { x: Int } type Wrap { r: Inner, tag: Int } fn main() { diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_one_field_record.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_one_field_record.silt index 67028846d..b6b53c7fd 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_one_field_record.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_one_field_record.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type One { x: Int } fn main() { println(d(One { x: 7 })) diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_pins_field_declaration_order.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_pins_field_declaration_order.silt index 86c2c2310..4c487c21b 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_pins_field_declaration_order.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_pins_field_declaration_order.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type R { z: Int, a: Int, m: Int } fn main() { println(d(R { z: 1, a: 2, m: 3 })) diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_three_field_record.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_three_field_record.silt index a14f57538..92d69c17c 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_three_field_record.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__display_three_field_record.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type R { a: Int, b: Int, c: String } fn main() { println(d(R { a: 1, b: 2, c: "hi" })) diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_nested_record_recurses_through_field_equal.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_nested_record_recurses_through_field_equal.silt index 642311696..70aef7158 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_nested_record_recurses_through_field_equal.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_nested_record_recurses_through_field_equal.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Inner { x: Int } type Wrap { r: Inner, tag: Int } fn main() { diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_one_field_record.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_one_field_record.silt index bc0182a3c..2d2d0c955 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_one_field_record.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_one_field_record.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type One { x: Int } fn main() { println(eq_gen(One { x: 1 }, One { x: 1 })) diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_three_field_record_left_fold.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_three_field_record_left_fold.silt index c588eca1b..8c1013fe4 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_three_field_record_left_fold.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__equal_three_field_record_left_fold.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type R { a: Int, b: Int, c: Int } fn main() { println(eq_gen(R { a: 1, b: 2, c: 3 }, R { a: 1, b: 2, c: 3 })) diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_nested_record_recurses_through_field_hash.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_nested_record_recurses_through_field_hash.silt index 9d3dcf8d8..f9b4ebec2 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_nested_record_recurses_through_field_hash.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_nested_record_recurses_through_field_hash.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type Inner { x: Int } type Wrap { r: Inner, tag: Int } fn main() { diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_one_field_record.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_one_field_record.silt index c9987e094..c209eefda 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_one_field_record.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_one_field_record.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type One { x: Int } fn main() { let h1 = h(One { x: 7 }) diff --git a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_three_field_record_combine.silt b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_three_field_record_combine.silt index a0207c717..148a73224 100644 --- a/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_three_field_record_combine.silt +++ b/tests/golden/meta/traits/round73_auto_derive_record_scaffold_collapse__hash_three_field_record_combine.silt @@ -1,7 +1,7 @@ -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } -fn h(a: a) -> Int where a: Hash { a.hash() } -fn d(a: a) -> String where a: Display { a.display() } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } +fn d(a: a) -> String where a: Display { "{a}" } type R { a: Int, b: Int, c: Int } fn main() { let h1 = h(R { a: 1, b: 2, c: 3 }) diff --git a/tests/golden/meta/traits/round75_typechecker_remap_and_dedup_tests__user_trait_for_unit_dispatches.silt b/tests/golden/meta/traits/round75_typechecker_remap_and_dedup_tests__user_trait_for_unit_dispatches.silt index 898fb1fe2..5fa559e4a 100644 --- a/tests/golden/meta/traits/round75_typechecker_remap_and_dedup_tests__user_trait_for_unit_dispatches.silt +++ b/tests/golden/meta/traits/round75_typechecker_remap_and_dedup_tests__user_trait_for_unit_dispatches.silt @@ -4,5 +4,5 @@ trait Greet { fn greet(self) -> String } trait Greet for Unit { fn greet(self) -> String { "hi" } } fn main() { let u = () - println(u.greet()) + println(Greet.greet(u)) } diff --git a/tests/golden/meta/traits/round75_typechecker_remap_and_dedup_tests__where_clause_instantiations_independent.silt b/tests/golden/meta/traits/round75_typechecker_remap_and_dedup_tests__where_clause_instantiations_independent.silt index 0efb17e58..80606590f 100644 --- a/tests/golden/meta/traits/round75_typechecker_remap_and_dedup_tests__where_clause_instantiations_independent.silt +++ b/tests/golden/meta/traits/round75_typechecker_remap_and_dedup_tests__where_clause_instantiations_independent.silt @@ -1,6 +1,6 @@ -- One constrained generic instantiated twice with different types: the -- where-clause tyvar of the first call must not leak into the second. -fn show(x: b, type b) -> String where b: Display { x.display() } +fn show(x: b, type b) -> String where b: Display { "{x}" } fn main() { let r1 = show(42, Int) diff --git a/tests/golden/meta/typecheck/type_audit_regressions__ambiguous_method_across_distinct_traits_names_both.silt b/tests/golden/meta/typecheck/type_audit_regressions__ambiguous_method_across_distinct_traits_names_both.silt deleted file mode 100644 index c2b0f884c..000000000 --- a/tests/golden/meta/typecheck/type_audit_regressions__ambiguous_method_across_distinct_traits_names_both.silt +++ /dev/null @@ -1,8 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: error[type]: ambiguous method 'name' on type 'Int': provided by traits First, Second -trait First { fn name(self) -> String } -trait Second { fn name(self) -> String } -trait First for Int { fn name(self) -> String { "first" } } -trait Second for Int { fn name(self) -> String { "second" } } -fn main() { println((5).name()) } diff --git a/tests/golden/meta/typecheck/type_audit_regressions__ambiguous_method_across_distinct_traits_rejected.silt b/tests/golden/meta/typecheck/type_audit_regressions__ambiguous_method_across_distinct_traits_rejected.silt deleted file mode 100644 index 3d7a72068..000000000 --- a/tests/golden/meta/typecheck/type_audit_regressions__ambiguous_method_across_distinct_traits_rejected.silt +++ /dev/null @@ -1,9 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: error[type] --- stderr-contains: ambiguous method 'name' on type 'Int' -trait First { fn name(self) -> String } -trait Second { fn name(self) -> String } -trait First for Int { fn name(self) -> String { "first" } } -trait Second for Int { fn name(self) -> String { "second" } } -fn main() { println((5).name()) } diff --git a/tests/golden/meta/typecheck/type_audit_regressions__receiver_method_correct_arity_accepted.silt b/tests/golden/meta/typecheck/type_audit_regressions__receiver_method_correct_arity_accepted.silt index db99a3537..45c5d6945 100644 --- a/tests/golden/meta/typecheck/type_audit_regressions__receiver_method_correct_arity_accepted.silt +++ b/tests/golden/meta/typecheck/type_audit_regressions__receiver_method_correct_arity_accepted.silt @@ -1,5 +1,6 @@ -- cmd: check -- exit: 0 +import string fn main() { - println("hello".display()) + println(string.from("hello")) } diff --git a/tests/golden/meta/typecheck/type_audit_regressions__receiver_method_extra_arg_rejected.silt b/tests/golden/meta/typecheck/type_audit_regressions__receiver_method_extra_arg_rejected.silt deleted file mode 100644 index d3529261f..000000000 --- a/tests/golden/meta/typecheck/type_audit_regressions__receiver_method_extra_arg_rejected.silt +++ /dev/null @@ -1,7 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: error[type] --- stderr-contains: method `display` expects 0 arguments, got 1 -fn main() { - println("hello".display("extra")) -} diff --git a/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_preserved_across_scheme_narrowing.silt b/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_preserved_across_scheme_narrowing.silt index 4ca6a9bfb..183d48083 100644 --- a/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_preserved_across_scheme_narrowing.silt +++ b/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_preserved_across_scheme_narrowing.silt @@ -4,7 +4,7 @@ -- stderr-contains: does not implement trait 'Doublable' trait Doublable { fn doubled(self) -> Int } trait Doublable for Int { fn doubled(self) -> Int { self * 2 } } -fn use_doublable(x: t) where t: Doublable { x.doubled() } +fn use_doublable(x: t) where t: Doublable { Doublable.doubled(x) } fn main() { let s = "text" let r = use_doublable(s) diff --git a/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_preserved_inside_callback_lambda.silt b/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_preserved_inside_callback_lambda.silt index ef516975e..a49a0cc09 100644 --- a/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_preserved_inside_callback_lambda.silt +++ b/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_preserved_inside_callback_lambda.silt @@ -5,7 +5,7 @@ trait Doubler { fn double(self) -> Int } trait Doubler for Int { fn double(self) -> Int { self * 2 } } fn run_callback(f) { f("hello") } -fn needs_doubler(x: a) where a: Doubler { x.double() } +fn needs_doubler(x: a) where a: Doubler { Doubler.double(x) } fn main() { let r = run_callback({ x -> needs_doubler(x) }) println(r) diff --git a/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_propagation_accepts_declared_constraint.silt b/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_propagation_accepts_declared_constraint.silt index b90d34eec..2ef450e69 100644 --- a/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_propagation_accepts_declared_constraint.silt +++ b/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_propagation_accepts_declared_constraint.silt @@ -6,6 +6,6 @@ trait Showable { trait Showable for Int { fn present(self) -> String { "i" } } -fn show(x: a) -> String where a: Showable { x.present() } +fn show(x: a) -> String where a: Showable { Showable.present(x) } fn indirect(x: a) -> String where a: Showable { show(x) } fn main() { println(indirect(5)) } diff --git a/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_propagation_rejects_missing_declaration.silt b/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_propagation_rejects_missing_declaration.silt index fc2820d48..f3af84246 100644 --- a/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_propagation_rejects_missing_declaration.silt +++ b/tests/golden/meta/typecheck/type_audit_regressions__where_constraint_propagation_rejects_missing_declaration.silt @@ -8,6 +8,6 @@ trait Showable { trait Showable for Int { fn present(self) -> String { "i" } } -fn show(x: a) -> String where a: Showable { x.present() } +fn show(x: a) -> String where a: Showable { Showable.present(x) } fn indirect(x: a) -> String { show(x) } fn main() { println(indirect(5)) } diff --git a/tests/golden/postgres/postgres_channels__the_rows_say_what_the_channels_carry.silt b/tests/golden/postgres/postgres_channels__the_rows_say_what_the_channels_carry.silt index bf95f2039..ea2112cbc 100644 --- a/tests/golden/postgres/postgres_channels__the_rows_say_what_the_channels_carry.silt +++ b/tests/golden/postgres/postgres_channels__the_rows_say_what_the_channels_carry.silt @@ -16,7 +16,7 @@ fn rows(pool: postgres.PgPool) -> Int { match channel.receive(typed) { Some(Ok(row)) -> row.amount Some(Err(e)) -> { - println(e.message()) + println(Error.message(e)) 0 } _ -> 0 @@ -32,7 +32,7 @@ fn notes(pool: postgres.PgPool) -> String { Some(note) -> "{note.channel}: {note.payload} from {note.pid}" None -> "closed" } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } diff --git a/tests/golden/postgres/typed_rows__a_mismatch_says_how_to_mend_it.silt b/tests/golden/postgres/typed_rows__a_mismatch_says_how_to_mend_it.silt index 3fc387db3..69871133a 100644 --- a/tests/golden/postgres/typed_rows__a_mismatch_says_how_to_mend_it.silt +++ b/tests/golden/postgres/typed_rows__a_mismatch_says_how_to_mend_it.silt @@ -22,5 +22,5 @@ fn main() { postgres.TypeMismatch("meta", "Meta", "NULL"), postgres.TypeMismatch("meta", "Meta", "jsonb: expected a record at n"), ] - mismatches |> list.each { e -> println(e.message()) } + mismatches |> list.each { e -> println(Error.message(e)) } } diff --git a/tests/golden/postgres/typed_rows__a_trait_method_on_a_type_variable_passes_its_connection_on.silt b/tests/golden/postgres/typed_rows__a_trait_method_on_a_type_variable_passes_its_connection_on.silt index 921e196dd..5d83e89a5 100644 --- a/tests/golden/postgres/typed_rows__a_trait_method_on_a_type_variable_passes_its_connection_on.silt +++ b/tests/golden/postgres/typed_rows__a_trait_method_on_a_type_variable_passes_its_connection_on.silt @@ -19,7 +19,7 @@ trait Runner for Repo { } fn run_with(r: r, c: a, ps: p) -> Result(Int, postgres.PostgresError) where r: Runner { - r.run(c, ps) + Runner.run(r, c, ps) } fn main() { diff --git a/tests/golden/postgres/typed_rows__a_trait_method_passes_its_connection_and_params_on.silt b/tests/golden/postgres/typed_rows__a_trait_method_passes_its_connection_and_params_on.silt index d9d2a78a4..98cf3fc4b 100644 --- a/tests/golden/postgres/typed_rows__a_trait_method_passes_its_connection_and_params_on.silt +++ b/tests/golden/postgres/typed_rows__a_trait_method_passes_its_connection_and_params_on.silt @@ -13,5 +13,5 @@ trait Runner for Repo { fn run(self, c: a, ps: p) -> Result(Int, postgres.PostgresError) { postgres.execute(c, "SELECT 1", ps) } } fn main() { - println(Repo { url: "" }.run("x", 5)) + println(Runner.run(Repo { url: "" }, "x", 5)) } diff --git a/tests/golden/postgres/typed_rows__a_trait_method_passes_its_connection_and_params_on.stderr b/tests/golden/postgres/typed_rows__a_trait_method_passes_its_connection_and_params_on.stderr index 519460368..701f18828 100644 --- a/tests/golden/postgres/typed_rows__a_trait_method_passes_its_connection_and_params_on.stderr +++ b/tests/golden/postgres/typed_rows__a_trait_method_passes_its_connection_and_params_on.stderr @@ -1,14 +1,14 @@ error[type]: the connection of `postgres.execute` must be a postgres.PgPool or a postgres.PgTx - --> typed_rows__a_trait_method_passes_its_connection_and_params_on.silt:16:32 + --> typed_rows__a_trait_method_passes_its_connection_and_params_on.silt:16:40 | - 16 | println(Repo { url: "" }.run("x", 5)) - | ^^^ the connection of `postgres.execute` must be a postgres.PgPool or a postgres.PgTx + 16 | println(Runner.run(Repo { url: "" }, "x", 5)) + | ^^^ the connection of `postgres.execute` must be a postgres.PgPool or a postgres.PgTx = note: `Repo.run` passes it to `postgres.execute` error[type]: the parameters of `postgres.execute` must be a tuple, got `Int` - --> typed_rows__a_trait_method_passes_its_connection_and_params_on.silt:16:37 + --> typed_rows__a_trait_method_passes_its_connection_and_params_on.silt:16:45 | - 16 | println(Repo { url: "" }.run("x", 5)) - | ^ the parameters of `postgres.execute` must be a tuple, got `Int` + 16 | println(Runner.run(Repo { url: "" }, "x", 5)) + | ^ the parameters of `postgres.execute` must be a tuple, got `Int` = note: `Repo.run` passes it to `postgres.execute` = help: write (id,) diff --git a/tests/golden/postgres/typed_rows__params_of_a_generic_function_are_checked_at_its_calls.silt b/tests/golden/postgres/typed_rows__params_of_a_generic_function_are_checked_at_its_calls.silt index 343997788..72b70936d 100644 --- a/tests/golden/postgres/typed_rows__params_of_a_generic_function_are_checked_at_its_calls.silt +++ b/tests/golden/postgres/typed_rows__params_of_a_generic_function_are_checked_at_its_calls.silt @@ -15,10 +15,10 @@ fn find(db: a, ps: p) -> Result(List(User), postgres.PostgresError) { fn main() { match find(0, (1,)) { Ok(_) -> println("a tuple: Ok") - Err(e) -> println("a tuple: {e.message()}") + Err(e) -> println("a tuple: {Error.message(e)}") } match find(0, 1) { Ok(_) -> println("an Int: Ok") - Err(e) -> println("an Int: {e.message()}") + Err(e) -> println("an Int: {Error.message(e)}") } } diff --git a/tests/golden/repros/SOUNDNESS.tsv b/tests/golden/repros/SOUNDNESS.tsv index 3a4005c55..9e6a0bf4e 100644 --- a/tests/golden/repros/SOUNDNESS.tsv +++ b/tests/golden/repros/SOUNDNESS.tsv @@ -31,8 +31,8 @@ repros/type_soundness/b4.silt holds reject E0314 TS-2.4: `+` on records through repros/type_soundness/b5.silt holds reject E0314 TS-2.4: unary `-` on a String through a polymorphic function repros/type_soundness/c1.silt - obsolete fn lambda; ported: lang/soundness/c1.silt repros/type_soundness/c2.silt - obsolete fn lambda; ported: lang/soundness/c2.silt -repros/type_soundness/c3.silt holds reject E0314 TS-2.1: `fn g(x) { x.greet() }` called with a String (decision D1) -repros/type_soundness/c4.silt holds reject E0308 TS-2.1: `x.greet()` on an annotated variable that has no bound +repros/type_soundness/c3.silt holds reject E0314 TS-2.1: `fn g(x) { Greet.greet(x) }` called with a String (decision D1) +repros/type_soundness/c4.silt holds reject E0305 TS-2.1: `x.greet()` on an annotated variable: a value of a type variable has no fields repros/type_soundness/c5.silt - obsolete fn lambda; ported: lang/soundness/c5.silt repros/type_soundness/cv2.silt holds reject E0301 TS-6: an anonymous record literal passed as a nominal `P` repros/type_soundness/cv3.silt holds reject E0301 TS-6: nominal records through a closed anonymous type; `==` is not transitive @@ -71,14 +71,14 @@ repros/type_soundness/deep9_12.silt holds accept TS-11: tuple type doubling, 12 repros/type_soundness/deep9_14.silt holds accept TS-11: tuple type doubling, 14 levels repros/type_soundness/deep9_16.silt holds accept TS-11: tuple type doubling, 16 levels repros/type_soundness/e1.silt holds reject E0301 TS-2.2: `r.message` is a row access whatever methods traits declare -repros/type_soundness/e10.silt holds accept TS-2.6: `.display()` on a closure parameter typed by the call +repros/type_soundness/e10.silt holds accept TS-2.6: interpolation of a closure parameter typed by the call repros/type_soundness/e11.silt holds accept TS-2.6: a user method on a closure parameter, pipe form repros/type_soundness/e12.silt - obsolete fn lambda; ported: lang/soundness/e12.silt repros/type_soundness/e2.silt holds reject E0301 TS-2.2: an unrelated `trait HasX { fn x(self) }` turns `r.x` into an unchecked call repros/type_soundness/e3.silt holds reject E0301 control for e2, without the trait repros/type_soundness/e4.silt - obsolete fn lambda; ported: lang/soundness/e4.silt repros/type_soundness/e5.silt - obsolete fn lambda; ported: lang/soundness/e5.silt -repros/type_soundness/e6.silt holds accept TS-2.6: `.display()` on a closure parameter typed by the call +repros/type_soundness/e6.silt holds accept TS-2.6: interpolation of a closure parameter typed by the call repros/type_soundness/e7.silt - obsolete fn lambda; ported: lang/soundness/e7.silt repros/type_soundness/e8.silt holds accept TS-2.6: user and built-in methods on closure parameters repros/type_soundness/e9.silt holds accept control for e8: enum receivers @@ -227,7 +227,7 @@ repros/type_soundness/u3.silt - obsolete a string literal with an unescaped `{`: repros/type_soundness/u4.silt holds accept TS-12: `let e = Err("x")` generalises: a constructor applied to values is a value repros/type_soundness/u5.silt - obsolete fn lambda; ported: lang/soundness/u5.silt repros/type_soundness/v1.silt holds reject E0308 a method on a `type a` descriptor that has no bound -repros/type_soundness/v2.silt holds reject E0308 a method the `where` clause does not give +repros/type_soundness/v2.silt holds reject E0305 a dot after a value of a bounded type variable is a field, whatever its bounds give repros/type_soundness/w1.silt holds reject E0314 TS-4: a `where` bound lost through a user higher-order function repros/type_soundness/w10.silt - obsolete fn lambda; ported: lang/soundness/w10.silt repros/type_soundness/w11.silt holds reject E0314 TS-4: a `where` bound lost through an annotated `let` @@ -278,7 +278,7 @@ repros/typechecker_arch/cv1_main_swapped holds accept TCA-1: as cv1_main_empty, repros/typechecker_arch/cv2_hello.silt holds accept control (TCA-13 counts its derived functions) repros/typechecker_arch/cv2_light.silt holds accept TCA-13: a user variant named like a builtin one repros/typechecker_arch/cv2_ver.silt holds output TCA-13: `<` and `.compare` order record fields alike, by declaration -repros/typechecker_arch/derive_d1.silt holds output TCA-7: derived `.display()` prints as `println` does +repros/typechecker_arch/derive_d1.silt holds output TCA-7: the derived display interpolates as `println` prints repros/typechecker_arch/derive_d2.silt holds output TCA-7: a user Display impl is what interpolation and `println` print, at any depth repros/typechecker_arch/derive_d3.silt holds output TCA-7: as derive_d2, for a record repros/typechecker_arch/derive_d4.silt holds reject E0331 TCA-7: Equal and Compare are sealed; a written impl is an error @@ -345,8 +345,8 @@ repros/typechecker_arch/t_chain3.silt holds reject E0301 TCA-2: as t_chain2, dep repros/typechecker_arch/t_handle.silt - obsolete fn lambda; a bare `Handle` names nothing (t_anno_handle) repros/typechecker_arch/t_key1.silt holds reject E0301 TCA-2: `fn bump(x: a) -> a { x + 1 }` violates its signature (t_rigid1) repros/typechecker_arch/t_key2.silt holds reject E0301 TCA-1: as t_key1, beside an impl method of the same name -repros/typechecker_arch/t_nonlocal1.silt holds reject E0301 control for t_nonlocal2 -repros/typechecker_arch/t_nonlocal2.silt holds reject E0301 TCA-4: an unrelated trait method `label` turns `p.label` into an unchecked call +repros/typechecker_arch/t_nonlocal1.silt holds reject E0305 control for t_nonlocal2 +repros/typechecker_arch/t_nonlocal2.silt holds reject E0305 TCA-4: a trait method `label` in sight does not change `p.label`: a field repros/typechecker_arch/t_poly_field.silt holds reject E0326 control: a row access has the field's type repros/typechecker_arch/t_poly_method.silt - obsolete fn lambda; ported: lang/soundness/t_poly_method.silt repros/typechecker_arch/t_poly_num.silt holds reject E0314 TCA-4: `add(true, false)` (decision D2) @@ -363,18 +363,18 @@ repros/typechecker_arch/t_where_hof.silt holds reject E0314 TCA-4: a `where` bou repros/typechecker_arch/t_where_paren.silt - obsolete `[f, ..]` is not a pattern; with `..rest` it is type_soundness/w3c repros/typechecker_arch/t_where_pipe_call.silt holds reject E0314 control: a `where` bound at `x |> f()` repros/typechecker_arch/t_where_pipe_plain.silt holds reject E0314 TCA-4: a `where` bound lost at `x |> f` -repros/typechecker_arch/t_tm_as_value.silt holds reject E0309 a trait method taken as a value (`let m = true.sh`) and called with its receiver: a method is called, not taken as a value -repros/typechecker_arch/t_method_value_generic_impl.silt holds reject E0309 a method of a generic impl taken as a value: a method is called, not taken as a value -repros/typechecker_arch/t_method_value_hof3.silt holds reject E0309 a method taken as a value and passed to list.map: a method is called, not taken as a value +repros/typechecker_arch/t_tm_as_value.silt holds reject E0305 a dot after a value is a field (`let m = true.sh`): a trait's method is taken through its trait +repros/typechecker_arch/t_method_value_generic_impl.silt holds reject E0305 a dot after a value of a generic impl's type is a field, not the impl's method +repros/typechecker_arch/t_method_value_hof3.silt holds reject E0305 a dot after a value is a field, also as a function passed to list.map lang/soundness/a5.silt holds reject E0301 a closure parameter's annotation is enforced lang/soundness/b1.silt holds reject E0314 TS-2.4: `==` and `<` on closures through polymorphic functions lang/soundness/c1.silt holds reject E0314 control for b1: the same with a declared Compare bound -lang/soundness/c2.silt holds reject E0314 TS-2.1: `.display()` on a closure through `fn show(x) { x.display() }` (decision D1) +lang/soundness/c2.silt holds reject E0314 TS-2.1: a closure shown through `fn show(x) { "{x}" }` (decision D1) lang/soundness/c5.silt holds reject E0314 TS-2.4: `<` on closures in a branch that is rarely taken -lang/soundness/d5.silt holds reject E0308 `.display()` on a closure +lang/soundness/d5.silt holds reject E0305 a dot after a closure: a closure has no fields lang/soundness/e12.silt holds accept TS-2.6: a closure calling a user method, then passed to list.map -lang/soundness/e4.silt holds reject E0301 a closure calling a method no trait declares -lang/soundness/e5.silt holds reject E0301 TS-2.1: `let n: Int = f(1)` where the closure returns `x.display()` +lang/soundness/e4.silt holds reject E0305 a closure reading a field no value it is given has +lang/soundness/e5.silt holds reject E0301 TS-2.1: `let n: Int = f(1)` where the closure returns `"{x}"` lang/soundness/e7.silt holds accept control: an annotated closure parameter lang/soundness/ex10.silt holds accept TS-10: literal fields in anonymous-record patterns add no coverage (false rejection) lang/soundness/ex5.silt holds reject E0320 `X(false, false)` is missed (the record match is exhaustive) @@ -404,7 +404,7 @@ lang/soundness/p4.silt holds reject E0301 a channel from a local closure is mono lang/soundness/q3.silt holds reject E0301 `loop(...)` arguments have the bindings' types lang/soundness/r3.silt holds accept a nominal record through an open row keeps its type lang/soundness/se2.silt holds reject E0201 TS-7.3: `self` in a closure outside a method -lang/soundness/t_poly_method.silt holds reject E0314 TCA-4: `show(f) + 1` over `fn show(x) { x.display() }` +lang/soundness/t_poly_method.silt holds reject E0314 TCA-4: `show(f) + 1` over `fn show(x) { "{x}" }` lang/soundness/u5.silt holds accept destructuring a tuple of values generalises each binding: `f(1)` and `f("s")` (false rejection) lang/soundness/w10.silt holds reject E0314 control for w2: the eta-expanded form lang/soundness/w12.silt holds reject E0314 TS-4: a Hash bound lost through list.map @@ -423,6 +423,6 @@ lang/soundness/every_tuple__self_is_not_a_tuple_of_chosen_elements.silt holds re lang/soundness/every_tuple__self_returned_as_a_tuple_of_a_variant.silt holds reject E0301 the same with a variant element lang/soundness/every_tuple__self_returned_as_a_tuple_of_a_record.silt holds reject E0301 the same with a record element lang/soundness/every_tuple__self_type_is_the_receivers.silt holds reject E0301 `Self` in an impl for every tuple was every tuple: a tuple of another type came back as the receiver's -lang/soundness/every_fn__not_called_through_the_type.silt holds reject E0309 `Fn.describe(5)`: the method of an impl for every function written through the type takes anything +lang/soundness/every_fn__not_called_through_the_type.silt holds reject E0308 `Fn.describe(5)`: a method that takes Self is called through its trait, never through the type lang/soundness/every_fn__self_is_not_called_taken_apart_or_shown.silt holds reject E0301 control: `self` of an impl for every function or tuple is not called, taken apart or shown lang/soundness/alias_impl__another_length_or_arity_has_no_impl.silt holds reject E0314 a bound answered by an impl for `(Int, Int)` or `Fn(Int) -> Int` (through an alias) held for a tuple of another length and a function of another arity diff --git a/tests/golden/repros/architecture/json1_alias.silt b/tests/golden/repros/architecture/json1_alias.silt index 33122c90f..89a760c34 100644 --- a/tests/golden/repros/architecture/json1_alias.silt +++ b/tests/golden/repros/architecture/json1_alias.silt @@ -14,6 +14,6 @@ fn main() { let raw = "\{\"title\": \"hi\", \"tags\": [\"a\", \"b\"], \"n\": 3\}" match json.parse(raw, Post) { Ok(p) -> println("ok: {p.title} {p.tags} {p.n}") - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/repros/architecture/json1_direct.silt b/tests/golden/repros/architecture/json1_direct.silt index 8eed8b3f0..5192d70f3 100644 --- a/tests/golden/repros/architecture/json1_direct.silt +++ b/tests/golden/repros/architecture/json1_direct.silt @@ -11,6 +11,6 @@ fn main() { let raw = "\{\"title\": \"hi\", \"tags\": [\"a\", \"b\"], \"n\": 3\}" match json.parse(raw, Post) { Ok(p) -> println("ok: {p.title} {p.tags} {p.n}") - Err(e) -> println("err: {e.message()}") + Err(e) -> println("err: {Error.message(e)}") } } diff --git a/tests/golden/repros/architecture/ord3_app/deps/sa/src/lib.silt b/tests/golden/repros/architecture/ord3_app/deps/sa/src/lib.silt index b6add6fe9..47d8f7e6e 100644 --- a/tests/golden/repros/architecture/ord3_app/deps/sa/src/lib.silt +++ b/tests/golden/repros/architecture/ord3_app/deps/sa/src/lib.silt @@ -2,7 +2,7 @@ import list pub type ColorA { Red, Blue } pub fn report() -> String { let lt = Red < Blue - let cmp = Red.compare(Blue) + let cmp = Compare.compare(Red, Blue) let sorted = [Blue, Red] |> list.sort let sorted_by = [Blue, Red] |> list.sort_by { c -> c } "Red < Blue = {lt}; Red.compare(Blue) = {cmp}; list.sort = {sorted}; sort_by = {sorted_by}" diff --git a/tests/golden/repros/compiler_vm/deep_m_compare_100.silt b/tests/golden/repros/compiler_vm/deep_m_compare_100.silt index 817566540..58a9d029f 100644 --- a/tests/golden/repros/compiler_vm/deep_m_compare_100.silt +++ b/tests/golden/repros/compiler_vm/deep_m_compare_100.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(100) let b = build(100) - a.compare(b) + Compare.compare(a, b) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_compare_200.silt b/tests/golden/repros/compiler_vm/deep_m_compare_200.silt index f8aeba9a6..76f0190a0 100644 --- a/tests/golden/repros/compiler_vm/deep_m_compare_200.silt +++ b/tests/golden/repros/compiler_vm/deep_m_compare_200.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(200) let b = build(200) - a.compare(b) + Compare.compare(a, b) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_compare_400.silt b/tests/golden/repros/compiler_vm/deep_m_compare_400.silt index 0ef5b3406..c5c75efa1 100644 --- a/tests/golden/repros/compiler_vm/deep_m_compare_400.silt +++ b/tests/golden/repros/compiler_vm/deep_m_compare_400.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(400) let b = build(400) - a.compare(b) + Compare.compare(a, b) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_compare_50.silt b/tests/golden/repros/compiler_vm/deep_m_compare_50.silt index b4fff219d..418913266 100644 --- a/tests/golden/repros/compiler_vm/deep_m_compare_50.silt +++ b/tests/golden/repros/compiler_vm/deep_m_compare_50.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(50) let b = build(50) - a.compare(b) + Compare.compare(a, b) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_display_100.silt b/tests/golden/repros/compiler_vm/deep_m_display_100.silt index 6d656b53f..fa0e818bb 100644 --- a/tests/golden/repros/compiler_vm/deep_m_display_100.silt +++ b/tests/golden/repros/compiler_vm/deep_m_display_100.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(100) let b = build(100) - a.display() + "{a}" } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_display_200.silt b/tests/golden/repros/compiler_vm/deep_m_display_200.silt index 20fda5920..866856eac 100644 --- a/tests/golden/repros/compiler_vm/deep_m_display_200.silt +++ b/tests/golden/repros/compiler_vm/deep_m_display_200.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(200) let b = build(200) - a.display() + "{a}" } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_display_400.silt b/tests/golden/repros/compiler_vm/deep_m_display_400.silt index 01b74ff46..4487b7235 100644 --- a/tests/golden/repros/compiler_vm/deep_m_display_400.silt +++ b/tests/golden/repros/compiler_vm/deep_m_display_400.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(400) let b = build(400) - a.display() + "{a}" } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_display_50.silt b/tests/golden/repros/compiler_vm/deep_m_display_50.silt index c81733d74..894c2f06c 100644 --- a/tests/golden/repros/compiler_vm/deep_m_display_50.silt +++ b/tests/golden/repros/compiler_vm/deep_m_display_50.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(50) let b = build(50) - a.display() + "{a}" } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_equal_100.silt b/tests/golden/repros/compiler_vm/deep_m_equal_100.silt index f816c2a7a..c50bb79c8 100644 --- a/tests/golden/repros/compiler_vm/deep_m_equal_100.silt +++ b/tests/golden/repros/compiler_vm/deep_m_equal_100.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(100) let b = build(100) - a.equal(b) + a == b } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_equal_200.silt b/tests/golden/repros/compiler_vm/deep_m_equal_200.silt index fda52286d..00a1beeea 100644 --- a/tests/golden/repros/compiler_vm/deep_m_equal_200.silt +++ b/tests/golden/repros/compiler_vm/deep_m_equal_200.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(200) let b = build(200) - a.equal(b) + a == b } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_equal_400.silt b/tests/golden/repros/compiler_vm/deep_m_equal_400.silt index bba9be8ca..f070345bc 100644 --- a/tests/golden/repros/compiler_vm/deep_m_equal_400.silt +++ b/tests/golden/repros/compiler_vm/deep_m_equal_400.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(400) let b = build(400) - a.equal(b) + a == b } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_equal_50.silt b/tests/golden/repros/compiler_vm/deep_m_equal_50.silt index cb5d0cff1..08739621b 100644 --- a/tests/golden/repros/compiler_vm/deep_m_equal_50.silt +++ b/tests/golden/repros/compiler_vm/deep_m_equal_50.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(50) let b = build(50) - a.equal(b) + a == b } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_hash_100.silt b/tests/golden/repros/compiler_vm/deep_m_hash_100.silt index 45604ff7b..552520081 100644 --- a/tests/golden/repros/compiler_vm/deep_m_hash_100.silt +++ b/tests/golden/repros/compiler_vm/deep_m_hash_100.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(100) let b = build(100) - a.hash() + Hash.hash(a) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_hash_200.silt b/tests/golden/repros/compiler_vm/deep_m_hash_200.silt index 91018f7d0..e164a47c2 100644 --- a/tests/golden/repros/compiler_vm/deep_m_hash_200.silt +++ b/tests/golden/repros/compiler_vm/deep_m_hash_200.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(200) let b = build(200) - a.hash() + Hash.hash(a) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_hash_400.silt b/tests/golden/repros/compiler_vm/deep_m_hash_400.silt index b12492601..b828c1ea2 100644 --- a/tests/golden/repros/compiler_vm/deep_m_hash_400.silt +++ b/tests/golden/repros/compiler_vm/deep_m_hash_400.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(400) let b = build(400) - a.hash() + Hash.hash(a) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_m_hash_50.silt b/tests/golden/repros/compiler_vm/deep_m_hash_50.silt index d187aa9cc..d08f27814 100644 --- a/tests/golden/repros/compiler_vm/deep_m_hash_50.silt +++ b/tests/golden/repros/compiler_vm/deep_m_hash_50.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(50) let b = build(50) - a.hash() + Hash.hash(a) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_rec_method.silt b/tests/golden/repros/compiler_vm/deep_rec_method.silt index 229d34620..979ae9d40 100644 --- a/tests/golden/repros/compiler_vm/deep_rec_method.silt +++ b/tests/golden/repros/compiler_vm/deep_rec_method.silt @@ -6,13 +6,13 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } fn main() { - println(1000.go()) - println(5000.go()) - println(20000.go()) - println(90000.go()) + println(Deep.go(1000)) + println(Deep.go(5000)) + println(Deep.go(20000)) + println(Deep.go(90000)) } diff --git a/tests/golden/repros/compiler_vm/deep_t_cmp_main_1000.silt b/tests/golden/repros/compiler_vm/deep_t_cmp_main_1000.silt index 040620bc3..4bda76886 100644 --- a/tests/golden/repros/compiler_vm/deep_t_cmp_main_1000.silt +++ b/tests/golden/repros/compiler_vm/deep_t_cmp_main_1000.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(1000) let b = build(1000) - a.compare(b) + Compare.compare(a, b) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_t_cmp_main_5000.silt b/tests/golden/repros/compiler_vm/deep_t_cmp_main_5000.silt index 9bce3e276..0bd809fd9 100644 --- a/tests/golden/repros/compiler_vm/deep_t_cmp_main_5000.silt +++ b/tests/golden/repros/compiler_vm/deep_t_cmp_main_5000.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(5000) let b = build(5000) - a.compare(b) + Compare.compare(a, b) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_t_cmp_task_30.silt b/tests/golden/repros/compiler_vm/deep_t_cmp_task_30.silt index 507d708cc..b74cb6713 100644 --- a/tests/golden/repros/compiler_vm/deep_t_cmp_task_30.silt +++ b/tests/golden/repros/compiler_vm/deep_t_cmp_task_30.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(30) let b = build(30) - a.compare(b) + Compare.compare(a, b) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_t_disp_task_30.silt b/tests/golden/repros/compiler_vm/deep_t_disp_task_30.silt index 3d60545d6..e8753ef61 100644 --- a/tests/golden/repros/compiler_vm/deep_t_disp_task_30.silt +++ b/tests/golden/repros/compiler_vm/deep_t_disp_task_30.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(30) let b = build(30) - a.display() == b.display() + "{a}" == "{b}" } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_t_eq_task_30.silt b/tests/golden/repros/compiler_vm/deep_t_eq_task_30.silt index a539bed0b..274be40ba 100644 --- a/tests/golden/repros/compiler_vm/deep_t_eq_task_30.silt +++ b/tests/golden/repros/compiler_vm/deep_t_eq_task_30.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(30) let b = build(30) - a.equal(b) + a == b } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_t_hash_task_30.silt b/tests/golden/repros/compiler_vm/deep_t_hash_task_30.silt index 4113ccd82..769b69056 100644 --- a/tests/golden/repros/compiler_vm/deep_t_hash_task_30.silt +++ b/tests/golden/repros/compiler_vm/deep_t_hash_task_30.silt @@ -20,7 +20,7 @@ fn build(n) { fn work() { let a = build(30) let b = build(30) - a.hash() == b.hash() + Hash.hash(a) == Hash.hash(b) } fn main() { diff --git a/tests/golden/repros/compiler_vm/deep_task_method_0.silt b/tests/golden/repros/compiler_vm/deep_task_method_0.silt index a73c56fce..8b5c9b46e 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_0.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_0.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_1.silt b/tests/golden/repros/compiler_vm/deep_task_method_1.silt index 7af990ba2..94d625cf6 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_1.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_1.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_12.silt b/tests/golden/repros/compiler_vm/deep_task_method_12.silt index 8ae8dcf0b..77b2f9e4a 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_12.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_12.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_160.silt b/tests/golden/repros/compiler_vm/deep_task_method_160.silt index e39fb67f1..4bd6d1b89 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_160.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_160.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_2.silt b/tests/golden/repros/compiler_vm/deep_task_method_2.silt index 6fc8166cf..0eb346266 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_2.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_2.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_20.silt b/tests/golden/repros/compiler_vm/deep_task_method_20.silt index 4ff2ae4aa..4c03a25ac 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_20.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_20.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_3.silt b/tests/golden/repros/compiler_vm/deep_task_method_3.silt index 1475352bd..3ce63ea67 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_3.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_3.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_40.silt b/tests/golden/repros/compiler_vm/deep_task_method_40.silt index 67ada68c1..c37af9ed4 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_40.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_40.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_400.silt b/tests/golden/repros/compiler_vm/deep_task_method_400.silt index cf2c64e1c..34c4db923 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_400.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_400.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_5.silt b/tests/golden/repros/compiler_vm/deep_task_method_5.silt index 1c454857a..e6d491e93 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_5.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_5.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_8.silt b/tests/golden/repros/compiler_vm/deep_task_method_8.silt index 009f4aa01..724393721 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_8.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_8.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/deep_task_method_80.silt b/tests/golden/repros/compiler_vm/deep_task_method_80.silt index 537c1ab5f..971af9d57 100644 --- a/tests/golden/repros/compiler_vm/deep_task_method_80.silt +++ b/tests/golden/repros/compiler_vm/deep_task_method_80.silt @@ -7,7 +7,7 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } diff --git a/tests/golden/repros/compiler_vm/modtest2_main/ma.silt b/tests/golden/repros/compiler_vm/modtest2_main/ma.silt index 0e7e47d9e..b60fd2fb9 100644 --- a/tests/golden/repros/compiler_vm/modtest2_main/ma.silt +++ b/tests/golden/repros/compiler_vm/modtest2_main/ma.silt @@ -3,4 +3,4 @@ pub fn make(n: Int) -> Item { Item { n: n } } trait Display for Item { fn display(self) -> String { "A-item({self.n})" } } -pub fn show(i: Item) -> String { i.display() } +pub fn show(i: Item) -> String { "{i}" } diff --git a/tests/golden/repros/compiler_vm/modtest2_main/mb.silt b/tests/golden/repros/compiler_vm/modtest2_main/mb.silt index 2ddc8b551..8f5410731 100644 --- a/tests/golden/repros/compiler_vm/modtest2_main/mb.silt +++ b/tests/golden/repros/compiler_vm/modtest2_main/mb.silt @@ -3,4 +3,4 @@ pub fn make(s: String) -> Item { Item { label: s } } trait Display for Item { fn display(self) -> String { "B-item({self.label})" } } -pub fn show(i: Item) -> String { i.display() } +pub fn show(i: Item) -> String { "{i}" } diff --git a/tests/golden/repros/compiler_vm/modtest_main/main.silt b/tests/golden/repros/compiler_vm/modtest_main/main.silt index c0885e6fa..970de3a00 100644 --- a/tests/golden/repros/compiler_vm/modtest_main/main.silt +++ b/tests/golden/repros/compiler_vm/modtest_main/main.silt @@ -11,6 +11,6 @@ fn main() { println("r == g: {r == g}") println("sorted: {list.sort([g, r])}") println("set size: {set.length(set.from_list([r, g]))}") - println("compare: {r.compare(g)}") + println("compare: {Compare.compare(r, g)}") println("display: {shapes.show(r)}") } diff --git a/tests/golden/repros/compiler_vm/modtest_main/shapes.silt b/tests/golden/repros/compiler_vm/modtest_main/shapes.silt index 8d84314a8..ecc9d1ea6 100644 --- a/tests/golden/repros/compiler_vm/modtest_main/shapes.silt +++ b/tests/golden/repros/compiler_vm/modtest_main/shapes.silt @@ -1,4 +1,4 @@ pub type Tag { Red, Green } pub fn red() -> Tag { Red } pub fn green() -> Tag { Green } -pub fn show(t: Tag) -> String { t.display() } +pub fn show(t: Tag) -> String { "{t}" } diff --git a/tests/golden/repros/compiler_vm/mx_float_finite.silt b/tests/golden/repros/compiler_vm/mx_float_finite.silt index 2fb61d68a..c8f3dadfa 100644 --- a/tests/golden/repros/compiler_vm/mx_float_finite.silt +++ b/tests/golden/repros/compiler_vm/mx_float_finite.silt @@ -20,11 +20,11 @@ fn main() { show("parse -0.0", float.parse("-0.0")) match json.parse("""{"v": 1e999}""", R) { Ok(r) -> println("json 1e999: {r.v}") - Err(e) -> println("json 1e999: Err {e.message()}") + Err(e) -> println("json 1e999: Err {Error.message(e)}") } match json.parse("""{"v": -0.0}""", R) { Ok(r) -> println("json -0.0: {r.v}") - Err(e) -> println("json -0.0: Err {e.message()}") + Err(e) -> println("json -0.0: Err {Error.message(e)}") } println("int.to_float max: {int.to_float(9223372036854775807)}") println("abs min: {int.abs(-9223372036854775807 - 1)}") diff --git a/tests/golden/repros/compiler_vm/mx_nan_equal.silt b/tests/golden/repros/compiler_vm/mx_nan_equal.silt index b2159873e..b975f2e25 100644 --- a/tests/golden/repros/compiler_vm/mx_nan_equal.silt +++ b/tests/golden/repros/compiler_vm/mx_nan_equal.silt @@ -4,6 +4,6 @@ fn main() { let nan = float.nan println("nan == nan: {nan == nan}") println("nan.equal(nan): {nan.equal(nan)}") - println("[nan].equal([nan]): {[nan].equal([nan])}") + println("[nan].equal([nan]): {[nan] == [nan]}") println("[nan] == [nan]: {[nan] == [nan]}") } diff --git a/tests/golden/repros/compiler_vm/mx_pipe_method.silt b/tests/golden/repros/compiler_vm/mx_pipe_method.silt index 7d9eaa7da..7ba96098b 100644 --- a/tests/golden/repros/compiler_vm/mx_pipe_method.silt +++ b/tests/golden/repros/compiler_vm/mx_pipe_method.silt @@ -9,6 +9,6 @@ trait Adder for Acc { type Color { Red, Green } fn main() { let a = Acc { base: 100 } - println(a.add(5)) - println(5 |> a.add()) + println(Adder.add(a, 5)) + println(Adder.add(a, 5)) } diff --git a/tests/golden/repros/compiler_vm/mx_pipe_method2.silt b/tests/golden/repros/compiler_vm/mx_pipe_method2.silt index d0c2293fa..95e4c7cdc 100644 --- a/tests/golden/repros/compiler_vm/mx_pipe_method2.silt +++ b/tests/golden/repros/compiler_vm/mx_pipe_method2.silt @@ -12,6 +12,6 @@ trait Namer for Color { } } fn main() { - println(Red.name("!")) - println("!" |> Red.name()) + println(Namer.name(Red, "!")) + println(Namer.name(Red, "!")) } diff --git a/tests/golden/repros/compiler_vm/mx_range_vs_list.silt b/tests/golden/repros/compiler_vm/mx_range_vs_list.silt index fa0a487ad..9b15bfc26 100644 --- a/tests/golden/repros/compiler_vm/mx_range_vs_list.silt +++ b/tests/golden/repros/compiler_vm/mx_range_vs_list.silt @@ -10,12 +10,12 @@ fn main() { println("r == l: {r == l}") println("display: {r} vs {l}") println("inspect: {io.inspect(r)} vs {io.inspect(l)}") - println(".display(): {r.display()} vs {l.display()}") - println("hash eq: {r.hash() == l.hash()}") + println(".display(): {r} vs {l}") + println("hash eq: {Hash.hash(r) == Hash.hash(l)}") println("set: {set.from_list([r, l])}") println("json: {json.stringify(r)} vs {json.stringify(l)}") println("empty: {5..1} == []: {5..1 == []}") - println("compare: {r.compare(l)} r < l: {r < l}") + println("compare: {Compare.compare(r, l)} r < l: {r < l}") let m = #{ r: "range" } println(map.get(m, l)) } diff --git a/tests/golden/repros/compiler_vm/mx_rec_order.silt b/tests/golden/repros/compiler_vm/mx_rec_order.silt index c78ffb6ae..cccf5c309 100644 --- a/tests/golden/repros/compiler_vm/mx_rec_order.silt +++ b/tests/golden/repros/compiler_vm/mx_rec_order.silt @@ -5,7 +5,7 @@ fn main() { let a = Ver { major: 1, build: 9 } let b = Ver { major: 2, build: 0 } println("a < b (operator): {a < b}") - println("a.compare(b) (trait): {a.compare(b)}") + println("a.compare(b) (trait): {Compare.compare(a, b)}") println("sorted: {list.sort([b, a])}") println("[a] < [b]: {[a] < [b]}") } diff --git a/tests/golden/repros/compiler_vm/mx_tco_method.silt b/tests/golden/repros/compiler_vm/mx_tco_method.silt index b84dd257c..f268f9d71 100644 --- a/tests/golden/repros/compiler_vm/mx_tco_method.silt +++ b/tests/golden/repros/compiler_vm/mx_tco_method.silt @@ -13,6 +13,6 @@ trait Counter for Int { } fn plain(n) { count(n, 0) } fn main() { - println(5.run()) + println(Counter.run(5)) println(plain(5)) } diff --git a/tests/golden/repros/compiler_vm/mx_toplevel_trait_order.silt b/tests/golden/repros/compiler_vm/mx_toplevel_trait_order.silt index 2d213c42f..2d81358b8 100644 --- a/tests/golden/repros/compiler_vm/mx_toplevel_trait_order.silt +++ b/tests/golden/repros/compiler_vm/mx_toplevel_trait_order.silt @@ -1,6 +1,7 @@ -- verdict: same +import string type Money { cents: Int } -let shown = Money { cents: 5 }.display() +let shown = string.from(Money { cents: 5 }) trait Display for Money { fn display(self) -> String { "USD {self.cents}" } } diff --git a/tests/golden/repros/compiler_vm/mx_tuple_cmp_method.silt b/tests/golden/repros/compiler_vm/mx_tuple_cmp_method.silt index 25b256cd4..2f08b0131 100644 --- a/tests/golden/repros/compiler_vm/mx_tuple_cmp_method.silt +++ b/tests/golden/repros/compiler_vm/mx_tuple_cmp_method.silt @@ -2,5 +2,5 @@ import list fn main() { println(list.sort([(1, 2), (1, 1)])) - println((1, 2).compare((1, 3))) + println(Compare.compare((1, 2), (1, 3))) } diff --git a/tests/golden/repros/compiler_vm/mx_user_traits.silt b/tests/golden/repros/compiler_vm/mx_user_traits.silt index ce3c62ca0..cfd82e249 100644 --- a/tests/golden/repros/compiler_vm/mx_user_traits.silt +++ b/tests/golden/repros/compiler_vm/mx_user_traits.silt @@ -19,12 +19,12 @@ trait Hash for Money { fn main() { let a = Money { cents: 1 } let b = Money { cents: 2 } - println("display(): {a.display()}") + println("display(): {a}") println("interp: {a}") println(a) println("list interp: {[a]}") - println("equal(): {a.equal(b)} ==: {a == b}") - println("compare(): {a.compare(b)} <: {a < b}") + println("equal(): {a == b} ==: {a == b}") + println("compare(): {Compare.compare(a, b)} <: {a < b}") println("sort: {list.sort([a, b])}") println("set size: {set.length(set.from_list([a, b]))}") println("Some interp: {Some(a)}") diff --git a/tests/golden/repros/compiler_vm/pat_anon_method.silt b/tests/golden/repros/compiler_vm/pat_anon_method.silt index beebfeceb..b14af5192 100644 --- a/tests/golden/repros/compiler_vm/pat_anon_method.silt +++ b/tests/golden/repros/compiler_vm/pat_anon_method.silt @@ -3,7 +3,7 @@ type P { x: Int, y: Int } trait Display for P { fn display(self) -> String { "P!" } } -fn show(p: P) -> String { p.display() } +fn show(p: P) -> String { "{p}" } fn main() { println(show({ x: 1, y: 2 })) } diff --git a/tests/golden/repros/compiler_vm/pkgs_app/deps/cola/src/lib.silt b/tests/golden/repros/compiler_vm/pkgs_app/deps/cola/src/lib.silt index 0e7e47d9e..b60fd2fb9 100644 --- a/tests/golden/repros/compiler_vm/pkgs_app/deps/cola/src/lib.silt +++ b/tests/golden/repros/compiler_vm/pkgs_app/deps/cola/src/lib.silt @@ -3,4 +3,4 @@ pub fn make(n: Int) -> Item { Item { n: n } } trait Display for Item { fn display(self) -> String { "A-item({self.n})" } } -pub fn show(i: Item) -> String { i.display() } +pub fn show(i: Item) -> String { "{i}" } diff --git a/tests/golden/repros/compiler_vm/pkgs_app/deps/colb/src/lib.silt b/tests/golden/repros/compiler_vm/pkgs_app/deps/colb/src/lib.silt index 2ddc8b551..8f5410731 100644 --- a/tests/golden/repros/compiler_vm/pkgs_app/deps/colb/src/lib.silt +++ b/tests/golden/repros/compiler_vm/pkgs_app/deps/colb/src/lib.silt @@ -3,4 +3,4 @@ pub fn make(s: String) -> Item { Item { label: s } } trait Display for Item { fn display(self) -> String { "B-item({self.label})" } } -pub fn show(i: Item) -> String { i.display() } +pub fn show(i: Item) -> String { "{i}" } diff --git a/tests/golden/repros/compiler_vm/t2.silt b/tests/golden/repros/compiler_vm/t2.silt index 664e0a8d3..23aa429ca 100644 --- a/tests/golden/repros/compiler_vm/t2.silt +++ b/tests/golden/repros/compiler_vm/t2.silt @@ -11,6 +11,6 @@ fn main() { println("list [b]<[a]: {[b] < [a]}") println("variant W(b) println("loaded {string.length(content)} bytes") Err(io.NotFound(path)) -> println("file does not exist: {path}") Err(io.PermissionDenied(path)) -> println("denied: {path}") - Err(e) -> println("error: {e.message()}") + Err(e) -> println("error: {Error.message(e)}") } } diff --git a/tests/golden/repros/frontend/docs_readme_3.silt b/tests/golden/repros/frontend/docs_readme_3.silt index fb148e0d8..7d7571fa0 100644 --- a/tests/golden/repros/frontend/docs_readme_3.silt +++ b/tests/golden/repros/frontend/docs_readme_3.silt @@ -8,9 +8,9 @@ fn main() { match io.read_file("settings.json") { Ok(content) -> match json.parse(content, Config) { Ok(cfg) -> println("loaded: {cfg.name}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } Err(io.NotFound(path)) -> println("no config at {path} — run `silt init` first") - Err(e) -> println("read error: {e.message()}") + Err(e) -> println("read error: {Error.message(e)}") } } diff --git a/tests/golden/repros/frontend/docs_traits_16.silt b/tests/golden/repros/frontend/docs_traits_16.silt index 42e5faad5..abe5586ee 100644 --- a/tests/golden/repros/frontend/docs_traits_16.silt +++ b/tests/golden/repros/frontend/docs_traits_16.silt @@ -11,6 +11,6 @@ trait Monoid for Int { fn main() { let zero = Int.empty() -- concrete dispatch - let five = Int.combine(2, 3) + let five = Monoid.combine(2, 3) println("{zero} {five}") } diff --git a/tests/golden/repros/frontend/docs_traits_17.silt b/tests/golden/repros/frontend/docs_traits_17.silt index e814fcd16..704ca6532 100644 --- a/tests/golden/repros/frontend/docs_traits_17.silt +++ b/tests/golden/repros/frontend/docs_traits_17.silt @@ -1,5 +1,6 @@ -- verdict: same import list +import string type Celsius { c: Float } @@ -9,6 +10,6 @@ trait Display for Celsius { fn main() { let temps = [Celsius { c: 20.0 }, Celsius { c: 25.5 }] - let rendered = list.map(temps, Celsius.display) + let rendered = list.map(temps, string.from) list.each(rendered) { line -> println(line) } } diff --git a/tests/golden/repros/frontend/ex_birthdays.silt b/tests/golden/repros/frontend/ex_birthdays.silt index 05e771011..e7e84f7e0 100644 --- a/tests/golden/repros/frontend/ex_birthdays.silt +++ b/tests/golden/repros/frontend/ex_birthdays.silt @@ -48,7 +48,7 @@ fn main() { ] """, Person) { Ok(p) -> p - Err(e) -> panic("Failed to parse people: {e.message()}") + Err(e) -> panic("Failed to parse people: {Error.message(e)}") } people |> list.each { p -> diff --git a/tests/golden/repros/frontend/ex_concurrent_processor.silt b/tests/golden/repros/frontend/ex_concurrent_processor.silt index f7481fbbe..0cc21f36f 100644 --- a/tests/golden/repros/frontend/ex_concurrent_processor.silt +++ b/tests/golden/repros/frontend/ex_concurrent_processor.silt @@ -102,7 +102,7 @@ fn main() { } Err(err_info) -> { let (path, err) = err_info - println("[Worker {worker_id}] FAILED {path}: {err.message()}") + println("[Worker {worker_id}] FAILED {path}: {Error.message(err)}") loop(collected + 1, successes, failures + 1) } } diff --git a/tests/golden/repros/frontend/ex_config_parser.silt b/tests/golden/repros/frontend/ex_config_parser.silt index 8ca85ac25..a9460a125 100644 --- a/tests/golden/repros/frontend/ex_config_parser.silt +++ b/tests/golden/repros/frontend/ex_config_parser.silt @@ -144,7 +144,7 @@ fn main() { -- Read the config file let text = match io.read_file("examples/app.conf") { Ok(t) -> t - Err(e) -> return println("Error reading examples/app.conf: {e.message()}") + Err(e) -> return println("Error reading examples/app.conf: {Error.message(e)}") } println("=== Parsing config file ===") println("") diff --git a/tests/golden/repros/frontend/ex_csv_analyzer.silt b/tests/golden/repros/frontend/ex_csv_analyzer.silt index 77ce87503..75ee3e408 100644 --- a/tests/golden/repros/frontend/ex_csv_analyzer.silt +++ b/tests/golden/repros/frontend/ex_csv_analyzer.silt @@ -113,7 +113,7 @@ fn main() { -- Read and parse CSV; bail out on IO errors with a rendered message. let content = match io.read_file("examples/data.csv") { Ok(text) -> text - Err(e) -> panic("Error reading data.csv: {e.message()}") + Err(e) -> panic("Error reading data.csv: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/tests/golden/repros/frontend/ex_diff_tool.silt b/tests/golden/repros/frontend/ex_diff_tool.silt index af143c97c..b350cb7d5 100644 --- a/tests/golden/repros/frontend/ex_diff_tool.silt +++ b/tests/golden/repros/frontend/ex_diff_tool.silt @@ -112,11 +112,11 @@ fn main() { -- Read both files, bailing out if either is missing. let old_content = match io.read_file("examples/data/original.txt") { Ok(content) -> content - Err(e) -> panic("Error reading original.txt: {e.message()}") + Err(e) -> panic("Error reading original.txt: {Error.message(e)}") } let new_content = match io.read_file("examples/data/modified.txt") { Ok(content) -> content - Err(e) -> panic("Error reading modified.txt: {e.message()}") + Err(e) -> panic("Error reading modified.txt: {Error.message(e)}") } -- Split into lines, filter out trailing empty line from final newline let old_lines = old_content diff --git a/tests/golden/repros/frontend/ex_expr_eval.silt b/tests/golden/repros/frontend/ex_expr_eval.silt index e9b06f500..ce5448e1c 100644 --- a/tests/golden/repros/frontend/ex_expr_eval.silt +++ b/tests/golden/repros/frontend/ex_expr_eval.silt @@ -21,9 +21,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -206,16 +206,16 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) let rpn_str = string.join(rpn, " ") println(" RPN: {rpn_str}") let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") println(" Depth: {depth(expr)}") @@ -226,10 +226,10 @@ fn main() { -- Demonstrate deep pattern matching println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -240,7 +240,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN println("\n=== From RPN ===\n") @@ -248,7 +248,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification println("\n=== Negative Pattern Simplification ===\n") @@ -256,7 +256,7 @@ fn main() { neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") } diff --git a/tests/golden/repros/frontend/ex_json_time.silt b/tests/golden/repros/frontend/ex_json_time.silt index 58a9fb8c0..6f61e777e 100644 --- a/tests/golden/repros/frontend/ex_json_time.silt +++ b/tests/golden/repros/frontend/ex_json_time.silt @@ -23,7 +23,7 @@ fn main() { -- Parse JSON with Date field let event = match json.parse("""{"name": "launch", "date": "2024-03-15"}""", Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("event: {event.name}") println("date: {event.date}") @@ -33,13 +33,13 @@ fn main() { -- Parse JSON with DateTime field let meeting = match json.parse("""{"title": "standup", "start": "2024-03-15T09:00:00"}""", Meeting) { Ok(m) -> m - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("meeting: {meeting.title} at {meeting.start}") -- Parse JSON with Time field let sched = match json.parse("""{"event": "lunch", "date": "2024-03-15", "time": "12:30:00"}""", Schedule) { Ok(s) -> s - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("schedule: {sched.event} on {sched.date} at {sched.time}") -- Parse a list of events @@ -51,7 +51,7 @@ fn main() { ] """, Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } events |> list.each { e -> @@ -67,6 +67,6 @@ fn main() { let bad = json.parse("""{"name": "oops", "date": "not-a-date"}""", Event) match bad { Ok(e) -> println("bad date: parsed as {e.name}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } } diff --git a/tests/golden/repros/frontend/ex_json_transform.silt b/tests/golden/repros/frontend/ex_json_transform.silt index 766686687..28ceddb9c 100644 --- a/tests/golden/repros/frontend/ex_json_transform.silt +++ b/tests/golden/repros/frontend/ex_json_transform.silt @@ -76,7 +76,7 @@ fn main() { -- Parse the JSON dataset let employees = match json.parse_list(employee_json, Employee) { Ok(emps) -> emps - Err(e) -> panic("Failed to parse employees: {e.message()}") + Err(e) -> panic("Failed to parse employees: {Error.message(e)}") } println("=== JSON Data Pipeline ===\n") -- 1. Group by department diff --git a/tests/golden/repros/frontend/ex_kvstore.silt b/tests/golden/repros/frontend/ex_kvstore.silt index d6438ca33..44c95e4b1 100644 --- a/tests/golden/repros/frontend/ex_kvstore.silt +++ b/tests/golden/repros/frontend/ex_kvstore.silt @@ -85,7 +85,7 @@ fn handle_save(store) { let json_str = json.stringify(store) match io.write_file(db_path, json_str) { Ok(_) -> println("OK - saved {map.length(store)} entries to {db_path}") - Err(e) -> println("Error saving: {e.message()}") + Err(e) -> println("Error saving: {Error.message(e)}") } store } @@ -93,7 +93,7 @@ fn handle_save(store) { fn handle_load() { match io.read_file(db_path) { Err(e) -> { - println("Error loading: {e.message()}") + println("Error loading: {Error.message(e)}") println("Starting with empty store.") #{} } @@ -104,7 +104,7 @@ fn handle_load() { loaded } Err(e) -> { - println("Error parsing JSON: {e.message()}") + println("Error parsing JSON: {Error.message(e)}") println("Starting with empty store.") #{} } diff --git a/tests/golden/repros/frontend/ex_link_checker.silt b/tests/golden/repros/frontend/ex_link_checker.silt index 67081dc02..396f5a504 100644 --- a/tests/golden/repros/frontend/ex_link_checker.silt +++ b/tests/golden/repros/frontend/ex_link_checker.silt @@ -24,7 +24,7 @@ fn main() { let content = match io.read_file(file_path) { Ok(c) -> c Err(e) -> { - println("Error reading file: {e.message()}") + println("Error reading file: {Error.message(e)}") return panic("Cannot continue without file") } } diff --git a/tests/golden/repros/frontend/ex_pipeline.silt b/tests/golden/repros/frontend/ex_pipeline.silt index 694ba236c..310b78862 100644 --- a/tests/golden/repros/frontend/ex_pipeline.silt +++ b/tests/golden/repros/frontend/ex_pipeline.silt @@ -160,7 +160,7 @@ fn main() { -- Read the log file; `return` in an Err arm bails out of main. let content = match io.read_file("examples/log.txt") { Ok(c) -> c - Err(e) -> return println("Error reading log file: {e.message()}") + Err(e) -> return println("Error reading log file: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/tests/golden/repros/frontend/ex_state_machine.silt b/tests/golden/repros/frontend/ex_state_machine.silt index bbb0968d4..f3361bcf5 100644 --- a/tests/golden/repros/frontend/ex_state_machine.silt +++ b/tests/golden/repros/frontend/ex_state_machine.silt @@ -52,7 +52,7 @@ trait Display for Event { -- Print a labeled displayable value (uses where clause) fn print_labeled(label: String, value: a) where a: Display { - println("{label}: {value.display()}") + println("{label}: {value}") } -- Print a list of displayable items with a header (uses where clause) @@ -60,7 +60,7 @@ fn print_labeled(label: String, value: a) where a: Display { fn print_items(header: String, items: List(a)) where a: Display { println(header) items - |> list.each { item -> println(" - {item.display()}") } + |> list.each { item -> println(" - {item}") } } -- Look up item info from inventory; returns (quantity, price) or None @@ -156,7 +156,7 @@ fn run_machine(events, initial_state, initial_inventory) { _ -> (state2, inventory2) } let (new_state, message, new_inv) = transition(state3, event, inventory3) - let new_log = list.append(log2, (step2, event.display(), state3, new_state, message)) + let new_log = list.append(log2, (step2, "{event}", state3, new_state, message)) (new_state, new_inv, step2 + 1, new_log) } -- If we're in Dispensing state, auto-resolve it first @@ -192,7 +192,7 @@ fn main() { _ -> "{step}" } println("[{step_str}] Event: {event_str}") - println(" {old_state.display()} -> {new_state.display()}") + println(" {old_state} -> {new_state}") println(" >> {message}") println("") } diff --git a/tests/golden/repros/frontend/ex_time_demo.silt b/tests/golden/repros/frontend/ex_time_demo.silt index 1f880945a..8ac405082 100644 --- a/tests/golden/repros/frontend/ex_time_demo.silt +++ b/tests/golden/repros/frontend/ex_time_demo.silt @@ -7,31 +7,31 @@ fn main() { let date = time.date(2024, 3, 15) match date { Ok(d) -> println("date: {d}") - Err(e) -> println("date error: {e.message()}") + Err(e) -> println("date error: {Error.message(e)}") } let bad_date = time.date(2024, 13, 1) match bad_date { Ok(d) -> println("bad date: {d}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } let t = time.time(14, 30, 0) match t { Ok(tm) -> println("time: {tm}") - Err(e) -> println("time error: {e.message()}") + Err(e) -> println("time error: {Error.message(e)}") } let bad_time = time.time(25, 0, 0) match bad_time { Ok(tm) -> println("bad time: {tm}") - Err(e) -> println("bad time: {e.message()}") + Err(e) -> println("bad time: {Error.message(e)}") } -- Compose date + time into datetime let d = match time.date(2024, 6, 15) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let tod = match time.time(9, 30, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt = time.datetime(d, tod) println("datetime: {dt}") @@ -43,11 +43,11 @@ fn main() { -- ── Formatting ────────────────────────────────────────────────────── let dt2_date = match time.date(2024, 12, 25) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let dt2_time = match time.time(18, 0, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt2 = time.datetime(dt2_date, dt2_time) println("formatted: {dt2 @@ -58,17 +58,17 @@ fn main() { let parsed = time.parse("2024-07-04 12:00:00", "%Y-%m-%d %H:%M:%S") match parsed { Ok(dt) -> println("parsed: {dt}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } let parsed_date = time.parse_date("2024-07-04", "%Y-%m-%d") match parsed_date { Ok(d) -> println("parsed date: {d}") - Err(e) -> println("parse date error: {e.message()}") + Err(e) -> println("parse date error: {Error.message(e)}") } let bad_parse = time.parse("not-a-date", "%Y-%m-%d %H:%M:%S") match bad_parse { Ok(dt) -> println("bad parse: {dt}") - Err(e) -> println("bad parse: {e.message()}") + Err(e) -> println("bad parse: {Error.message(e)}") } -- ── Date arithmetic ───────────────────────────────────────────────── let future = today @@ -80,14 +80,14 @@ fn main() { -- Month arithmetic with end-of-month clamping let jan31 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let feb_result = jan31 |> time.add_months(1) println("Jan 31 + 1 month = {feb_result}") let mar31 = match time.date(2024, 3, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let prev = mar31 |> time.add_months(-1) @@ -123,11 +123,11 @@ fn main() { println("today is: {weekday}") let d_start = match time.date(2024, 1, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d_end = match time.date(2024, 12, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let days = time.days_between(d_start, d_end) println("days in 2024: {days}") @@ -139,11 +139,11 @@ fn main() { -- ── Comparison ────────────────────────────────────────────────────── let d1 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d2 = match time.date(2024, 2, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } println("Jan 31 < Feb 1: {d1 < d2}") println("Feb 1 > Jan 31: {d2 > d1}") diff --git a/tests/golden/repros/frontend/ex_todo.silt b/tests/golden/repros/frontend/ex_todo.silt index 5f2fbf48e..d3e9b0b4a 100644 --- a/tests/golden/repros/frontend/ex_todo.silt +++ b/tests/golden/repros/frontend/ex_todo.silt @@ -62,7 +62,7 @@ fn save_todos(todos, path) { let content = json.stringify(todos) match io.write_file(path, content) { Ok(_) -> println(" Saved {list.length(todos)} todo(s) to {path}") - Err(e) -> println(" Error saving: {e.message()}") + Err(e) -> println(" Error saving: {Error.message(e)}") } } @@ -79,13 +79,13 @@ fn load_todos(path) { todos } Err(e) -> { - println(" Error parsing: {e.message()}") + println(" Error parsing: {Error.message(e)}") [] } } } Err(e) -> { - println(" Error loading: {e.message()}") + println(" Error loading: {Error.message(e)}") [] } } diff --git a/tests/golden/repros/frontend/ex_trait_zoo.silt b/tests/golden/repros/frontend/ex_trait_zoo.silt index 3a9a20278..8489e44fa 100644 --- a/tests/golden/repros/frontend/ex_trait_zoo.silt +++ b/tests/golden/repros/frontend/ex_trait_zoo.silt @@ -53,7 +53,7 @@ trait Display for Color { trait Display for Styled { fn display(self) -> String { match self { - Styled(shape, color) -> "{shape.display()} in {color.display()}" + Styled(shape, color) -> "{shape} in {color}" } } } @@ -98,7 +98,7 @@ trait Perimeter for Shape { -- Generic function with where clause fn describe(item: a) where a: Display { - item.display() + "{item}" } -- Format a float to 4 decimal places diff --git a/tests/golden/repros/frontend/ex_traits.silt b/tests/golden/repros/frontend/ex_traits.silt index 28b81e689..2973ab18e 100644 --- a/tests/golden/repros/frontend/ex_traits.silt +++ b/tests/golden/repros/frontend/ex_traits.silt @@ -26,7 +26,7 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") shapes - |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } diff --git a/tests/golden/repros/frontend/exfmt_birthdays.silt b/tests/golden/repros/frontend/exfmt_birthdays.silt index 05e771011..e7e84f7e0 100644 --- a/tests/golden/repros/frontend/exfmt_birthdays.silt +++ b/tests/golden/repros/frontend/exfmt_birthdays.silt @@ -48,7 +48,7 @@ fn main() { ] """, Person) { Ok(p) -> p - Err(e) -> panic("Failed to parse people: {e.message()}") + Err(e) -> panic("Failed to parse people: {Error.message(e)}") } people |> list.each { p -> diff --git a/tests/golden/repros/frontend/exfmt_concurrent_processor.silt b/tests/golden/repros/frontend/exfmt_concurrent_processor.silt index f7481fbbe..0cc21f36f 100644 --- a/tests/golden/repros/frontend/exfmt_concurrent_processor.silt +++ b/tests/golden/repros/frontend/exfmt_concurrent_processor.silt @@ -102,7 +102,7 @@ fn main() { } Err(err_info) -> { let (path, err) = err_info - println("[Worker {worker_id}] FAILED {path}: {err.message()}") + println("[Worker {worker_id}] FAILED {path}: {Error.message(err)}") loop(collected + 1, successes, failures + 1) } } diff --git a/tests/golden/repros/frontend/exfmt_config_parser.silt b/tests/golden/repros/frontend/exfmt_config_parser.silt index 8ca85ac25..a9460a125 100644 --- a/tests/golden/repros/frontend/exfmt_config_parser.silt +++ b/tests/golden/repros/frontend/exfmt_config_parser.silt @@ -144,7 +144,7 @@ fn main() { -- Read the config file let text = match io.read_file("examples/app.conf") { Ok(t) -> t - Err(e) -> return println("Error reading examples/app.conf: {e.message()}") + Err(e) -> return println("Error reading examples/app.conf: {Error.message(e)}") } println("=== Parsing config file ===") println("") diff --git a/tests/golden/repros/frontend/exfmt_csv_analyzer.silt b/tests/golden/repros/frontend/exfmt_csv_analyzer.silt index 77ce87503..75ee3e408 100644 --- a/tests/golden/repros/frontend/exfmt_csv_analyzer.silt +++ b/tests/golden/repros/frontend/exfmt_csv_analyzer.silt @@ -113,7 +113,7 @@ fn main() { -- Read and parse CSV; bail out on IO errors with a rendered message. let content = match io.read_file("examples/data.csv") { Ok(text) -> text - Err(e) -> panic("Error reading data.csv: {e.message()}") + Err(e) -> panic("Error reading data.csv: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/tests/golden/repros/frontend/exfmt_diff_tool.silt b/tests/golden/repros/frontend/exfmt_diff_tool.silt index af143c97c..b350cb7d5 100644 --- a/tests/golden/repros/frontend/exfmt_diff_tool.silt +++ b/tests/golden/repros/frontend/exfmt_diff_tool.silt @@ -112,11 +112,11 @@ fn main() { -- Read both files, bailing out if either is missing. let old_content = match io.read_file("examples/data/original.txt") { Ok(content) -> content - Err(e) -> panic("Error reading original.txt: {e.message()}") + Err(e) -> panic("Error reading original.txt: {Error.message(e)}") } let new_content = match io.read_file("examples/data/modified.txt") { Ok(content) -> content - Err(e) -> panic("Error reading modified.txt: {e.message()}") + Err(e) -> panic("Error reading modified.txt: {Error.message(e)}") } -- Split into lines, filter out trailing empty line from final newline let old_lines = old_content diff --git a/tests/golden/repros/frontend/exfmt_expr_eval.silt b/tests/golden/repros/frontend/exfmt_expr_eval.silt index e9b06f500..ce5448e1c 100644 --- a/tests/golden/repros/frontend/exfmt_expr_eval.silt +++ b/tests/golden/repros/frontend/exfmt_expr_eval.silt @@ -21,9 +21,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -206,16 +206,16 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) let rpn_str = string.join(rpn, " ") println(" RPN: {rpn_str}") let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") println(" Depth: {depth(expr)}") @@ -226,10 +226,10 @@ fn main() { -- Demonstrate deep pattern matching println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -240,7 +240,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN println("\n=== From RPN ===\n") @@ -248,7 +248,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification println("\n=== Negative Pattern Simplification ===\n") @@ -256,7 +256,7 @@ fn main() { neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") } diff --git a/tests/golden/repros/frontend/exfmt_json_time.silt b/tests/golden/repros/frontend/exfmt_json_time.silt index 58a9fb8c0..6f61e777e 100644 --- a/tests/golden/repros/frontend/exfmt_json_time.silt +++ b/tests/golden/repros/frontend/exfmt_json_time.silt @@ -23,7 +23,7 @@ fn main() { -- Parse JSON with Date field let event = match json.parse("""{"name": "launch", "date": "2024-03-15"}""", Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("event: {event.name}") println("date: {event.date}") @@ -33,13 +33,13 @@ fn main() { -- Parse JSON with DateTime field let meeting = match json.parse("""{"title": "standup", "start": "2024-03-15T09:00:00"}""", Meeting) { Ok(m) -> m - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("meeting: {meeting.title} at {meeting.start}") -- Parse JSON with Time field let sched = match json.parse("""{"event": "lunch", "date": "2024-03-15", "time": "12:30:00"}""", Schedule) { Ok(s) -> s - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("schedule: {sched.event} on {sched.date} at {sched.time}") -- Parse a list of events @@ -51,7 +51,7 @@ fn main() { ] """, Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } events |> list.each { e -> @@ -67,6 +67,6 @@ fn main() { let bad = json.parse("""{"name": "oops", "date": "not-a-date"}""", Event) match bad { Ok(e) -> println("bad date: parsed as {e.name}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } } diff --git a/tests/golden/repros/frontend/exfmt_json_transform.silt b/tests/golden/repros/frontend/exfmt_json_transform.silt index 766686687..28ceddb9c 100644 --- a/tests/golden/repros/frontend/exfmt_json_transform.silt +++ b/tests/golden/repros/frontend/exfmt_json_transform.silt @@ -76,7 +76,7 @@ fn main() { -- Parse the JSON dataset let employees = match json.parse_list(employee_json, Employee) { Ok(emps) -> emps - Err(e) -> panic("Failed to parse employees: {e.message()}") + Err(e) -> panic("Failed to parse employees: {Error.message(e)}") } println("=== JSON Data Pipeline ===\n") -- 1. Group by department diff --git a/tests/golden/repros/frontend/exfmt_kvstore.silt b/tests/golden/repros/frontend/exfmt_kvstore.silt index d6438ca33..44c95e4b1 100644 --- a/tests/golden/repros/frontend/exfmt_kvstore.silt +++ b/tests/golden/repros/frontend/exfmt_kvstore.silt @@ -85,7 +85,7 @@ fn handle_save(store) { let json_str = json.stringify(store) match io.write_file(db_path, json_str) { Ok(_) -> println("OK - saved {map.length(store)} entries to {db_path}") - Err(e) -> println("Error saving: {e.message()}") + Err(e) -> println("Error saving: {Error.message(e)}") } store } @@ -93,7 +93,7 @@ fn handle_save(store) { fn handle_load() { match io.read_file(db_path) { Err(e) -> { - println("Error loading: {e.message()}") + println("Error loading: {Error.message(e)}") println("Starting with empty store.") #{} } @@ -104,7 +104,7 @@ fn handle_load() { loaded } Err(e) -> { - println("Error parsing JSON: {e.message()}") + println("Error parsing JSON: {Error.message(e)}") println("Starting with empty store.") #{} } diff --git a/tests/golden/repros/frontend/exfmt_link_checker.silt b/tests/golden/repros/frontend/exfmt_link_checker.silt index 67081dc02..396f5a504 100644 --- a/tests/golden/repros/frontend/exfmt_link_checker.silt +++ b/tests/golden/repros/frontend/exfmt_link_checker.silt @@ -24,7 +24,7 @@ fn main() { let content = match io.read_file(file_path) { Ok(c) -> c Err(e) -> { - println("Error reading file: {e.message()}") + println("Error reading file: {Error.message(e)}") return panic("Cannot continue without file") } } diff --git a/tests/golden/repros/frontend/exfmt_pipeline.silt b/tests/golden/repros/frontend/exfmt_pipeline.silt index 694ba236c..310b78862 100644 --- a/tests/golden/repros/frontend/exfmt_pipeline.silt +++ b/tests/golden/repros/frontend/exfmt_pipeline.silt @@ -160,7 +160,7 @@ fn main() { -- Read the log file; `return` in an Err arm bails out of main. let content = match io.read_file("examples/log.txt") { Ok(c) -> c - Err(e) -> return println("Error reading log file: {e.message()}") + Err(e) -> return println("Error reading log file: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/tests/golden/repros/frontend/exfmt_state_machine.silt b/tests/golden/repros/frontend/exfmt_state_machine.silt index bbb0968d4..f3361bcf5 100644 --- a/tests/golden/repros/frontend/exfmt_state_machine.silt +++ b/tests/golden/repros/frontend/exfmt_state_machine.silt @@ -52,7 +52,7 @@ trait Display for Event { -- Print a labeled displayable value (uses where clause) fn print_labeled(label: String, value: a) where a: Display { - println("{label}: {value.display()}") + println("{label}: {value}") } -- Print a list of displayable items with a header (uses where clause) @@ -60,7 +60,7 @@ fn print_labeled(label: String, value: a) where a: Display { fn print_items(header: String, items: List(a)) where a: Display { println(header) items - |> list.each { item -> println(" - {item.display()}") } + |> list.each { item -> println(" - {item}") } } -- Look up item info from inventory; returns (quantity, price) or None @@ -156,7 +156,7 @@ fn run_machine(events, initial_state, initial_inventory) { _ -> (state2, inventory2) } let (new_state, message, new_inv) = transition(state3, event, inventory3) - let new_log = list.append(log2, (step2, event.display(), state3, new_state, message)) + let new_log = list.append(log2, (step2, "{event}", state3, new_state, message)) (new_state, new_inv, step2 + 1, new_log) } -- If we're in Dispensing state, auto-resolve it first @@ -192,7 +192,7 @@ fn main() { _ -> "{step}" } println("[{step_str}] Event: {event_str}") - println(" {old_state.display()} -> {new_state.display()}") + println(" {old_state} -> {new_state}") println(" >> {message}") println("") } diff --git a/tests/golden/repros/frontend/exfmt_time_demo.silt b/tests/golden/repros/frontend/exfmt_time_demo.silt index 1f880945a..8ac405082 100644 --- a/tests/golden/repros/frontend/exfmt_time_demo.silt +++ b/tests/golden/repros/frontend/exfmt_time_demo.silt @@ -7,31 +7,31 @@ fn main() { let date = time.date(2024, 3, 15) match date { Ok(d) -> println("date: {d}") - Err(e) -> println("date error: {e.message()}") + Err(e) -> println("date error: {Error.message(e)}") } let bad_date = time.date(2024, 13, 1) match bad_date { Ok(d) -> println("bad date: {d}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } let t = time.time(14, 30, 0) match t { Ok(tm) -> println("time: {tm}") - Err(e) -> println("time error: {e.message()}") + Err(e) -> println("time error: {Error.message(e)}") } let bad_time = time.time(25, 0, 0) match bad_time { Ok(tm) -> println("bad time: {tm}") - Err(e) -> println("bad time: {e.message()}") + Err(e) -> println("bad time: {Error.message(e)}") } -- Compose date + time into datetime let d = match time.date(2024, 6, 15) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let tod = match time.time(9, 30, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt = time.datetime(d, tod) println("datetime: {dt}") @@ -43,11 +43,11 @@ fn main() { -- ── Formatting ────────────────────────────────────────────────────── let dt2_date = match time.date(2024, 12, 25) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let dt2_time = match time.time(18, 0, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt2 = time.datetime(dt2_date, dt2_time) println("formatted: {dt2 @@ -58,17 +58,17 @@ fn main() { let parsed = time.parse("2024-07-04 12:00:00", "%Y-%m-%d %H:%M:%S") match parsed { Ok(dt) -> println("parsed: {dt}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } let parsed_date = time.parse_date("2024-07-04", "%Y-%m-%d") match parsed_date { Ok(d) -> println("parsed date: {d}") - Err(e) -> println("parse date error: {e.message()}") + Err(e) -> println("parse date error: {Error.message(e)}") } let bad_parse = time.parse("not-a-date", "%Y-%m-%d %H:%M:%S") match bad_parse { Ok(dt) -> println("bad parse: {dt}") - Err(e) -> println("bad parse: {e.message()}") + Err(e) -> println("bad parse: {Error.message(e)}") } -- ── Date arithmetic ───────────────────────────────────────────────── let future = today @@ -80,14 +80,14 @@ fn main() { -- Month arithmetic with end-of-month clamping let jan31 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let feb_result = jan31 |> time.add_months(1) println("Jan 31 + 1 month = {feb_result}") let mar31 = match time.date(2024, 3, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let prev = mar31 |> time.add_months(-1) @@ -123,11 +123,11 @@ fn main() { println("today is: {weekday}") let d_start = match time.date(2024, 1, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d_end = match time.date(2024, 12, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let days = time.days_between(d_start, d_end) println("days in 2024: {days}") @@ -139,11 +139,11 @@ fn main() { -- ── Comparison ────────────────────────────────────────────────────── let d1 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d2 = match time.date(2024, 2, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } println("Jan 31 < Feb 1: {d1 < d2}") println("Feb 1 > Jan 31: {d2 > d1}") diff --git a/tests/golden/repros/frontend/exfmt_todo.silt b/tests/golden/repros/frontend/exfmt_todo.silt index 5f2fbf48e..d3e9b0b4a 100644 --- a/tests/golden/repros/frontend/exfmt_todo.silt +++ b/tests/golden/repros/frontend/exfmt_todo.silt @@ -62,7 +62,7 @@ fn save_todos(todos, path) { let content = json.stringify(todos) match io.write_file(path, content) { Ok(_) -> println(" Saved {list.length(todos)} todo(s) to {path}") - Err(e) -> println(" Error saving: {e.message()}") + Err(e) -> println(" Error saving: {Error.message(e)}") } } @@ -79,13 +79,13 @@ fn load_todos(path) { todos } Err(e) -> { - println(" Error parsing: {e.message()}") + println(" Error parsing: {Error.message(e)}") [] } } } Err(e) -> { - println(" Error loading: {e.message()}") + println(" Error loading: {Error.message(e)}") [] } } diff --git a/tests/golden/repros/frontend/exfmt_trait_zoo.silt b/tests/golden/repros/frontend/exfmt_trait_zoo.silt index 3a9a20278..8489e44fa 100644 --- a/tests/golden/repros/frontend/exfmt_trait_zoo.silt +++ b/tests/golden/repros/frontend/exfmt_trait_zoo.silt @@ -53,7 +53,7 @@ trait Display for Color { trait Display for Styled { fn display(self) -> String { match self { - Styled(shape, color) -> "{shape.display()} in {color.display()}" + Styled(shape, color) -> "{shape} in {color}" } } } @@ -98,7 +98,7 @@ trait Perimeter for Shape { -- Generic function with where clause fn describe(item: a) where a: Display { - item.display() + "{item}" } -- Format a float to 4 decimal places diff --git a/tests/golden/repros/frontend/exfmt_traits.silt b/tests/golden/repros/frontend/exfmt_traits.silt index 28b81e689..2973ab18e 100644 --- a/tests/golden/repros/frontend/exfmt_traits.silt +++ b/tests/golden/repros/frontend/exfmt_traits.silt @@ -26,7 +26,7 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") shapes - |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } diff --git a/tests/golden/repros/frontend/hist_expr_eval_old.silt b/tests/golden/repros/frontend/hist_expr_eval_old.silt index db5dac439..e0a8e9210 100644 --- a/tests/golden/repros/frontend/hist_expr_eval_old.silt +++ b/tests/golden/repros/frontend/hist_expr_eval_old.silt @@ -21,9 +21,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -205,11 +205,11 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) @@ -218,7 +218,7 @@ fn main() { -- Round-trip: from_rpn(to_rpn(expr)) should equal original let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") @@ -231,10 +231,10 @@ fn main() { println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -254,7 +254,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN @@ -263,7 +263,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification @@ -275,7 +275,7 @@ fn main() { ] neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") diff --git a/tests/golden/repros/frontend/hist_t.silt b/tests/golden/repros/frontend/hist_t.silt index f0a34ec3e..cc254275e 100644 --- a/tests/golden/repros/frontend/hist_t.silt +++ b/tests/golden/repros/frontend/hist_t.silt @@ -21,9 +21,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -206,17 +206,17 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) let rpn_str = string.join(rpn, " ") println(" RPN: {rpn_str}") -- Round-trip: from_rpn(to_rpn(expr)) should equal original let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") println(" Depth: {depth(expr)}") @@ -226,10 +226,10 @@ fn main() { -- Demonstrate deep pattern matching println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -240,7 +240,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN println("\n=== From RPN ===\n") @@ -248,7 +248,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification println("\n=== Negative Pattern Simplification ===\n") @@ -256,7 +256,7 @@ fn main() { neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") } diff --git a/tests/golden/repros/lang_design/cross_dup_main/m1.silt b/tests/golden/repros/lang_design/cross_dup_main/m1.silt index 88ed5f969..d4e974693 100644 --- a/tests/golden/repros/lang_design/cross_dup_main/m1.silt +++ b/tests/golden/repros/lang_design/cross_dup_main/m1.silt @@ -3,4 +3,4 @@ trait Display for Item { fn display(self) -> String { "m1 item {self.id}" } } pub fn mk() -> Item { Item { id: 1 } } -pub fn show(i: Item) -> String { i.display() } +pub fn show(i: Item) -> String { "{i}" } diff --git a/tests/golden/repros/lang_design/cross_dup_main/m2.silt b/tests/golden/repros/lang_design/cross_dup_main/m2.silt index 9cc6e7f16..7181019f3 100644 --- a/tests/golden/repros/lang_design/cross_dup_main/m2.silt +++ b/tests/golden/repros/lang_design/cross_dup_main/m2.silt @@ -3,4 +3,4 @@ trait Display for Item { fn display(self) -> String { "m2 item {self.name}" } } pub fn mk() -> Item { Item { name: "n" } } -pub fn show(i: Item) -> String { i.display() } +pub fn show(i: Item) -> String { "{i}" } diff --git a/tests/golden/repros/lang_design/d01.silt b/tests/golden/repros/lang_design/d01.silt index bbd4446a4..8270d0572 100644 --- a/tests/golden/repros/lang_design/d01.silt +++ b/tests/golden/repros/lang_design/d01.silt @@ -4,11 +4,11 @@ type E { A(Int, String), B, C(P) } fn main() { let p = P { x: 1, y: 2.0, s: "hi" } println(p) - println(p.display()) + println("{p}") println("{p}") println([p]) println(C(p)) - println(C(p).display()) + println("{C(p)}") println("{C(p)}") println(A(1, "s")) println(Some("s")) @@ -17,6 +17,6 @@ fn main() { println(#{"k": "v"}) println("s") println(Some(2.0)) - println(2.0.display()) + println("{2.0}") println(Ok(())) } diff --git a/tests/golden/repros/lang_design/d02.silt b/tests/golden/repros/lang_design/d02.silt index 0c9f49be0..1a11fade7 100644 --- a/tests/golden/repros/lang_design/d02.silt +++ b/tests/golden/repros/lang_design/d02.silt @@ -2,6 +2,7 @@ import list import map import set +import string type P { x: Int } type W { inner: P } type E { Wrap(P) } @@ -19,17 +20,17 @@ fn main() { let q = P { x: 2 } println(p) println("{p}") - println(p.display()) + println("{p}") println([p]) println(Some(p)) println((p, 1)) println(W { inner: p }) - println(W { inner: p }.display()) + println(string.from(W { inner: p })) println(Wrap(p)) println(#{ "k": p }) println("--- equal (custom: always true)") println(p == q) - println(p.equal(q)) + println(p == q) println([p] == [q]) println(Some(p) == Some(q)) println(W { inner: p } == W { inner: q }) @@ -37,7 +38,7 @@ fn main() { println(set.length(#[p, q])) println("--- compare (custom: reversed)") println(p < q) - println(p.compare(q)) + println(Compare.compare(p, q)) println(list.sort([p, q])) println([p] < [q]) println(W { inner: p } < W { inner: q }) diff --git a/tests/golden/repros/lang_design/d03.silt b/tests/golden/repros/lang_design/d03.silt index 7835351a9..15b85431d 100644 --- a/tests/golden/repros/lang_design/d03.silt +++ b/tests/golden/repros/lang_design/d03.silt @@ -12,7 +12,7 @@ trait Display for Shape { fn main() { let s = Circle(5.0) - println(s.display()) + println("{s}") println("{s}") println(s) println([s]) diff --git a/tests/golden/repros/lang_design/diag_t1_param_trait.silt b/tests/golden/repros/lang_design/diag_t1_param_trait.silt index 7c1660681..0b4c01673 100644 --- a/tests/golden/repros/lang_design/diag_t1_param_trait.silt +++ b/tests/golden/repros/lang_design/diag_t1_param_trait.silt @@ -9,6 +9,6 @@ trait Convert(Float) for String { fn convert(self) -> Float { 2.0 } } fn main() { - let a: Int = "x".convert() + let a: Int = Convert.convert("x") println(a) } diff --git a/tests/golden/repros/lang_design/diag_x3.silt b/tests/golden/repros/lang_design/diag_x3.silt index 9bdfa08fd..eea90d5a4 100644 --- a/tests/golden/repros/lang_design/diag_x3.silt +++ b/tests/golden/repros/lang_design/diag_x3.silt @@ -1,5 +1,6 @@ -- verdict: same +import string fn main() { - let f = Int.display + let f = string.from println(f(5)) } diff --git a/tests/golden/repros/lang_design/ex_pr_12.silt b/tests/golden/repros/lang_design/ex_pr_12.silt index 444cf1c49..6321f9387 100644 --- a/tests/golden/repros/lang_design/ex_pr_12.silt +++ b/tests/golden/repros/lang_design/ex_pr_12.silt @@ -11,5 +11,5 @@ fn g(a) { a } fn main() { let nan = 0.0 / 0.0 let inf = 1.0 / 0.0 - println(true.display()) + println("{true}") } diff --git a/tests/golden/repros/lang_design/ex_pr_8.silt b/tests/golden/repros/lang_design/ex_pr_8.silt index 0d7bcf127..8db26c81c 100644 --- a/tests/golden/repros/lang_design/ex_pr_8.silt +++ b/tests/golden/repros/lang_design/ex_pr_8.silt @@ -11,5 +11,5 @@ fn g(a) { a } fn main() { let nan = 0.0 / 0.0 let inf = 1.0 / 0.0 - println({x: 1}.equal({x: 1})) + println({x: 1} == {x: 1}) } diff --git a/tests/golden/repros/lang_design/ex_pr_9.silt b/tests/golden/repros/lang_design/ex_pr_9.silt index a90e87d6a..a00092379 100644 --- a/tests/golden/repros/lang_design/ex_pr_9.silt +++ b/tests/golden/repros/lang_design/ex_pr_9.silt @@ -11,5 +11,5 @@ fn g(a) { a } fn main() { let nan = 0.0 / 0.0 let inf = 1.0 / 0.0 - println(true.equal(true)) + println(true == true) } diff --git a/tests/golden/repros/lang_design/g05.silt b/tests/golden/repros/lang_design/g05.silt index e61a74188..cd330bd83 100644 --- a/tests/golden/repros/lang_design/g05.silt +++ b/tests/golden/repros/lang_design/g05.silt @@ -1,5 +1,5 @@ -- verdict: same -fn describe(x) { x.display() } +fn describe(x) { "{x}" } fn id(x) { x } fn main() { println(describe(1)) diff --git a/tests/golden/repros/lang_design/g06.silt b/tests/golden/repros/lang_design/g06.silt index fd79b823d..32f600394 100644 --- a/tests/golden/repros/lang_design/g06.silt +++ b/tests/golden/repros/lang_design/g06.silt @@ -1,6 +1,6 @@ -- verdict: same import list -fn describe(x: a) -> String where a: Display { x.display() } +fn describe(x: a) -> String where a: Display { "{x}" } fn biggest(xs: List(a)) -> List(a) where a: Compare { list.sort(xs) } fn id(x) { x } fn main() { diff --git a/tests/golden/repros/lang_design/g07.silt b/tests/golden/repros/lang_design/g07.silt index 1b5f68eba..3517c5b9a 100644 --- a/tests/golden/repros/lang_design/g07.silt +++ b/tests/golden/repros/lang_design/g07.silt @@ -3,7 +3,7 @@ trait Shape { fn area(self) -> Int } type Sq { s: Int } trait Shape for Sq { fn area(self) -> Int { self.s * self.s } } -fn total(a, b) { a.area() + b.area() } +fn total(a, b) { Shape.area(a) + Shape.area(b) } fn main() { println(total(Sq { s: 2 }, Sq { s: 3 })) diff --git a/tests/golden/repros/lang_design/traits_copy.silt b/tests/golden/repros/lang_design/traits_copy.silt index 28b81e689..2973ab18e 100644 --- a/tests/golden/repros/lang_design/traits_copy.silt +++ b/tests/golden/repros/lang_design/traits_copy.silt @@ -26,7 +26,7 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") shapes - |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } diff --git a/tests/golden/repros/lang_design/w01.silt b/tests/golden/repros/lang_design/w01.silt index f36ec6c8c..c1c11393f 100644 --- a/tests/golden/repros/lang_design/w01.silt +++ b/tests/golden/repros/lang_design/w01.silt @@ -5,7 +5,7 @@ fn a(s) { let res = int.parse(s) when let Ok(n) = res else { match res { - Err(e) -> return Err("bad: {e.message()}") + Err(e) -> return Err("bad: {Error.message(e)}") Ok(_) -> panic("unreachable") } } diff --git a/tests/golden/repros/lang_design/w02.silt b/tests/golden/repros/lang_design/w02.silt index af110741b..353d438c7 100644 --- a/tests/golden/repros/lang_design/w02.silt +++ b/tests/golden/repros/lang_design/w02.silt @@ -5,7 +5,7 @@ import int fn b(s) { let n = match int.parse(s) { Ok(n) -> n - Err(e) -> return Err("bad: {e.message()}") + Err(e) -> return Err("bad: {Error.message(e)}") } Ok(n + 1) } diff --git a/tests/golden/repros/packages/t3_main/moda.silt b/tests/golden/repros/packages/t3_main/moda.silt index ab84e4f92..41e873026 100644 --- a/tests/golden/repros/packages/t3_main/moda.silt +++ b/tests/golden/repros/packages/t3_main/moda.silt @@ -3,7 +3,7 @@ trait Show { fn show(self) -> String } trait Show for Tok { fn show(self) -> String { "moda-Tok" } } -pub fn describe() -> String { T(1).show() } +pub fn describe() -> String { Show.show(T(1)) } pub fn unwrap() -> Int { match T(41) { T(n) -> n + 1 diff --git a/tests/golden/repros/packages/t3_main/modb.silt b/tests/golden/repros/packages/t3_main/modb.silt index 4dc33da45..c23f288da 100644 --- a/tests/golden/repros/packages/t3_main/modb.silt +++ b/tests/golden/repros/packages/t3_main/modb.silt @@ -3,4 +3,4 @@ trait Show { fn show(self) -> String } trait Show for Tok { fn show(self) -> String { "modb-Tok" } } -pub fn describe() -> String { T("a", "b").show() } +pub fn describe() -> String { Show.show(T("a", "b")) } diff --git a/tests/golden/repros/packages/t3b_main/moda.silt b/tests/golden/repros/packages/t3b_main/moda.silt index 3c77b5f79..ab464004c 100644 --- a/tests/golden/repros/packages/t3b_main/moda.silt +++ b/tests/golden/repros/packages/t3b_main/moda.silt @@ -3,4 +3,4 @@ trait Show { fn show(self) -> String } trait Show for Tok { fn show(self) -> String { "moda-Tok" } } -pub fn describe() -> String { T(1).show() } +pub fn describe() -> String { Show.show(T(1)) } diff --git a/tests/golden/repros/packages/t3b_main/modb.silt b/tests/golden/repros/packages/t3b_main/modb.silt index d43e95d76..fa7868ea3 100644 --- a/tests/golden/repros/packages/t3b_main/modb.silt +++ b/tests/golden/repros/packages/t3b_main/modb.silt @@ -3,4 +3,4 @@ trait Show { fn show(self) -> String } trait Show for Tok { fn show(self) -> String { "modb-Tok" } } -pub fn describe() -> String { T(2).show() } +pub fn describe() -> String { Show.show(T(2)) } diff --git a/tests/golden/repros/packages/t5_v3/main.silt b/tests/golden/repros/packages/t5_v3/main.silt index 7c7fd8d58..8a60f5060 100644 --- a/tests/golden/repros/packages/t5_v3/main.silt +++ b/tests/golden/repros/packages/t5_v3/main.silt @@ -2,5 +2,5 @@ import lib1 fn main() { let s = lib1.mk() - println(s.peek()) + println(lib1.Peek.peek(s)) } diff --git a/tests/golden/repros/packages/t5b_disp.silt b/tests/golden/repros/packages/t5b_disp.silt index 7d08bd97b..ecc778e5e 100644 --- a/tests/golden/repros/packages/t5b_disp.silt +++ b/tests/golden/repros/packages/t5b_disp.silt @@ -1,10 +1,11 @@ -- verdict: same +import string type Node { Leaf(String), Nil } trait Display for Node { fn display(self) -> String { "custom" } } fn main() { println("{Leaf("x")}") - println(Leaf("x").display()) + println(string.from(Leaf("x"))) println(Leaf("x")) } diff --git a/tests/golden/repros/packages/tq_q1/main.silt b/tests/golden/repros/packages/tq_q1/main.silt index 1ab6d8d56..84291efdb 100644 --- a/tests/golden/repros/packages/tq_q1/main.silt +++ b/tests/golden/repros/packages/tq_q1/main.silt @@ -1,4 +1,4 @@ -- verdict: same import shapes -fn f(s: shapes.Shape) -> Int { s.area() } +fn f(s: shapes.Shape) -> Int { shapes.Area.area(s) } fn main() { println(f(shapes.unit())) } diff --git a/tests/golden/repros/packages/tq_q3/main.silt b/tests/golden/repros/packages/tq_q3/main.silt index ddeade89c..1a6211caf 100644 --- a/tests/golden/repros/packages/tq_q3/main.silt +++ b/tests/golden/repros/packages/tq_q3/main.silt @@ -8,6 +8,6 @@ fn main() { println(a) println(b) println(a == b) - println(a.area()) + println(shapes.Area.area(a)) println(c.area()) } diff --git a/tests/golden/repros/packages/tq_q4/main.silt b/tests/golden/repros/packages/tq_q4/main.silt index 3348b63c4..9f92dcc01 100644 --- a/tests/golden/repros/packages/tq_q4/main.silt +++ b/tests/golden/repros/packages/tq_q4/main.silt @@ -4,4 +4,4 @@ type Sq { side: Int } trait shapes.Area for Sq { fn area(self) -> Int { self.side * self.side } } -fn main() { println(Sq { side: 3 }.area()) } +fn main() { println(shapes.Area.area(Sq { side: 3 })) } diff --git a/tests/golden/repros/packages/tq_q5/main.silt b/tests/golden/repros/packages/tq_q5/main.silt index 3348b63c4..9f92dcc01 100644 --- a/tests/golden/repros/packages/tq_q5/main.silt +++ b/tests/golden/repros/packages/tq_q5/main.silt @@ -4,4 +4,4 @@ type Sq { side: Int } trait shapes.Area for Sq { fn area(self) -> Int { self.side * self.side } } -fn main() { println(Sq { side: 3 }.area()) } +fn main() { println(shapes.Area.area(Sq { side: 3 })) } diff --git a/tests/golden/repros/packages/tq_q8/main.silt b/tests/golden/repros/packages/tq_q8/main.silt index 786ee2809..ac733ed23 100644 --- a/tests/golden/repros/packages/tq_q8/main.silt +++ b/tests/golden/repros/packages/tq_q8/main.silt @@ -1,5 +1,5 @@ -- verdict: same -import shapes.{ unit } +import shapes.{ unit, Area } fn f(s: Shape) -> Int { match s { Circle(r) -> r @@ -8,5 +8,5 @@ fn f(s: Shape) -> Int { } fn main() { println(f(Square(4))) - println(unit().area()) + println(Area.area(unit())) } diff --git a/tests/golden/repros/stdlib/t_negzero2.silt b/tests/golden/repros/stdlib/t_negzero2.silt index 8ef15b202..c4cc5e969 100644 --- a/tests/golden/repros/stdlib/t_negzero2.silt +++ b/tests/golden/repros/stdlib/t_negzero2.silt @@ -5,8 +5,8 @@ import string fn main() { when let Ok(z) = float.parse("-0.0") else { return } println(z == 0.0) - println(z.hash() == (0.0).hash()) - println(z.compare(0.0)) + println(Hash.hash(z) == Hash.hash(0.0)) + println(Compare.compare(z, 0.0)) println(string.from(z) == string.from(0.0)) println("{z}") println(list.sort([0.0, z, 0.0])) diff --git a/tests/golden/repros/stdlib/t_tostr.silt b/tests/golden/repros/stdlib/t_tostr.silt index 056335962..caa9b807d 100644 --- a/tests/golden/repros/stdlib/t_tostr.silt +++ b/tests/golden/repros/stdlib/t_tostr.silt @@ -8,11 +8,11 @@ import list import json fn main() { let n = 42 - println([string.from(n), string.from(n), "{n}", n.display(), io.inspect(n), json.stringify(n)]) + println([string.from(n), string.from(n), "{n}", "{n}", io.inspect(n), json.stringify(n)]) let f = 2.0 - println([string.from(f), string.from(f), "{f}", f.display(), io.inspect(f), json.stringify(f)]) + println([string.from(f), string.from(f), "{f}", "{f}", io.inspect(f), json.stringify(f)]) let s = "hi" - println([string.from(s), "{s}", s.display(), io.inspect(s), json.stringify(s)]) + println([string.from(s), "{s}", "{s}", io.inspect(s), json.stringify(s)]) let xs = ["a", "b c", ""] println(string.from(xs)) println(io.inspect(xs)) diff --git a/tests/golden/repros/test_arch/run_ex_birthdays.silt b/tests/golden/repros/test_arch/run_ex_birthdays.silt index 05e771011..e7e84f7e0 100644 --- a/tests/golden/repros/test_arch/run_ex_birthdays.silt +++ b/tests/golden/repros/test_arch/run_ex_birthdays.silt @@ -48,7 +48,7 @@ fn main() { ] """, Person) { Ok(p) -> p - Err(e) -> panic("Failed to parse people: {e.message()}") + Err(e) -> panic("Failed to parse people: {Error.message(e)}") } people |> list.each { p -> diff --git a/tests/golden/repros/test_arch/run_ex_concurrent_processor.silt b/tests/golden/repros/test_arch/run_ex_concurrent_processor.silt index f7481fbbe..0cc21f36f 100644 --- a/tests/golden/repros/test_arch/run_ex_concurrent_processor.silt +++ b/tests/golden/repros/test_arch/run_ex_concurrent_processor.silt @@ -102,7 +102,7 @@ fn main() { } Err(err_info) -> { let (path, err) = err_info - println("[Worker {worker_id}] FAILED {path}: {err.message()}") + println("[Worker {worker_id}] FAILED {path}: {Error.message(err)}") loop(collected + 1, successes, failures + 1) } } diff --git a/tests/golden/repros/test_arch/run_ex_config_parser.silt b/tests/golden/repros/test_arch/run_ex_config_parser.silt index 8ca85ac25..a9460a125 100644 --- a/tests/golden/repros/test_arch/run_ex_config_parser.silt +++ b/tests/golden/repros/test_arch/run_ex_config_parser.silt @@ -144,7 +144,7 @@ fn main() { -- Read the config file let text = match io.read_file("examples/app.conf") { Ok(t) -> t - Err(e) -> return println("Error reading examples/app.conf: {e.message()}") + Err(e) -> return println("Error reading examples/app.conf: {Error.message(e)}") } println("=== Parsing config file ===") println("") diff --git a/tests/golden/repros/test_arch/run_ex_csv_analyzer.silt b/tests/golden/repros/test_arch/run_ex_csv_analyzer.silt index 77ce87503..75ee3e408 100644 --- a/tests/golden/repros/test_arch/run_ex_csv_analyzer.silt +++ b/tests/golden/repros/test_arch/run_ex_csv_analyzer.silt @@ -113,7 +113,7 @@ fn main() { -- Read and parse CSV; bail out on IO errors with a rendered message. let content = match io.read_file("examples/data.csv") { Ok(text) -> text - Err(e) -> panic("Error reading data.csv: {e.message()}") + Err(e) -> panic("Error reading data.csv: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/tests/golden/repros/test_arch/run_ex_diff_tool.silt b/tests/golden/repros/test_arch/run_ex_diff_tool.silt index af143c97c..b350cb7d5 100644 --- a/tests/golden/repros/test_arch/run_ex_diff_tool.silt +++ b/tests/golden/repros/test_arch/run_ex_diff_tool.silt @@ -112,11 +112,11 @@ fn main() { -- Read both files, bailing out if either is missing. let old_content = match io.read_file("examples/data/original.txt") { Ok(content) -> content - Err(e) -> panic("Error reading original.txt: {e.message()}") + Err(e) -> panic("Error reading original.txt: {Error.message(e)}") } let new_content = match io.read_file("examples/data/modified.txt") { Ok(content) -> content - Err(e) -> panic("Error reading modified.txt: {e.message()}") + Err(e) -> panic("Error reading modified.txt: {Error.message(e)}") } -- Split into lines, filter out trailing empty line from final newline let old_lines = old_content diff --git a/tests/golden/repros/test_arch/run_ex_expr_eval.silt b/tests/golden/repros/test_arch/run_ex_expr_eval.silt index e9b06f500..ce5448e1c 100644 --- a/tests/golden/repros/test_arch/run_ex_expr_eval.silt +++ b/tests/golden/repros/test_arch/run_ex_expr_eval.silt @@ -21,9 +21,9 @@ trait Display for Expr { fn display(self) -> String { match self { Num(n) -> "{n}" - Add(l, r) -> "({l.display()} + {r.display()})" - Mul(l, r) -> "({l.display()} * {r.display()})" - Neg(e) -> "(-{e.display()})" + Add(l, r) -> "({l} + {r})" + Mul(l, r) -> "({l} * {r})" + Neg(e) -> "(-{e})" } } } @@ -206,16 +206,16 @@ fn main() { examples |> list.each { (label, expr) -> println("--- {label} ---") - println(" Pretty: {expr.display()}") + println(" Pretty: {expr}") println(" Eval: {eval(expr)}") let s = simplify(expr) - println(" Simplified: {s.display()}") + println(" Simplified: {s}") println(" Eval(simp): {eval(s)}") let rpn = to_rpn(expr) let rpn_str = string.join(rpn, " ") println(" RPN: {rpn_str}") let roundtrip = from_rpn(rpn) - println(" Roundtrip: {roundtrip.display()}") + println(" Roundtrip: {roundtrip}") println(" RT eval: {eval(roundtrip)}") println(" Complexity: {complexity(expr)}") println(" Depth: {depth(expr)}") @@ -226,10 +226,10 @@ fn main() { -- Demonstrate deep pattern matching println("=== Deep Pattern Matching ===\n") let nested = Add(Mul(Num(1), Add(Num(2), Num(3))), Neg(Num(4))) - println("Expression: {nested.display()}") + println("Expression: {nested}") -- Deep match: recognize specific shapes let description = match nested { - Add(Mul(Num(1), inner), _) -> "addition with 1*({inner.display()}) on left" + Add(Mul(Num(1), inner), _) -> "addition with 1*({inner}) on left" Add(_, Neg(Num(n))) -> "addition with -{n} on right" _ -> "other" } @@ -240,7 +240,7 @@ fn main() { test_exprs |> list.each { expr -> let cls = complexity(expr) - println(" {expr.display()} -> {cls}") + println(" {expr} -> {cls}") } -- Build from RPN println("\n=== From RPN ===\n") @@ -248,7 +248,7 @@ fn main() { let rpn_str = string.join(rpn_input, " ") let parsed = from_rpn(rpn_input) println(" RPN input: {rpn_str}") - println(" Parsed: {parsed.display()}") + println(" Parsed: {parsed}") println(" Eval: {eval(parsed)}") -- Demonstrate negative pattern simplification println("\n=== Negative Pattern Simplification ===\n") @@ -256,7 +256,7 @@ fn main() { neg_examples |> list.each { (label, expr) -> let s = simplify(expr) - println(" {label} -> simplified: {s.display()} = {eval(s)}") + println(" {label} -> simplified: {s} = {eval(s)}") } println("\nDone!") } diff --git a/tests/golden/repros/test_arch/run_ex_json_time.silt b/tests/golden/repros/test_arch/run_ex_json_time.silt index 58a9fb8c0..6f61e777e 100644 --- a/tests/golden/repros/test_arch/run_ex_json_time.silt +++ b/tests/golden/repros/test_arch/run_ex_json_time.silt @@ -23,7 +23,7 @@ fn main() { -- Parse JSON with Date field let event = match json.parse("""{"name": "launch", "date": "2024-03-15"}""", Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("event: {event.name}") println("date: {event.date}") @@ -33,13 +33,13 @@ fn main() { -- Parse JSON with DateTime field let meeting = match json.parse("""{"title": "standup", "start": "2024-03-15T09:00:00"}""", Meeting) { Ok(m) -> m - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("meeting: {meeting.title} at {meeting.start}") -- Parse JSON with Time field let sched = match json.parse("""{"event": "lunch", "date": "2024-03-15", "time": "12:30:00"}""", Schedule) { Ok(s) -> s - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } println("schedule: {sched.event} on {sched.date} at {sched.time}") -- Parse a list of events @@ -51,7 +51,7 @@ fn main() { ] """, Event) { Ok(e) -> e - Err(e) -> panic("parse error: {e.message()}") + Err(e) -> panic("parse error: {Error.message(e)}") } events |> list.each { e -> @@ -67,6 +67,6 @@ fn main() { let bad = json.parse("""{"name": "oops", "date": "not-a-date"}""", Event) match bad { Ok(e) -> println("bad date: parsed as {e.name}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } } diff --git a/tests/golden/repros/test_arch/run_ex_json_transform.silt b/tests/golden/repros/test_arch/run_ex_json_transform.silt index 766686687..28ceddb9c 100644 --- a/tests/golden/repros/test_arch/run_ex_json_transform.silt +++ b/tests/golden/repros/test_arch/run_ex_json_transform.silt @@ -76,7 +76,7 @@ fn main() { -- Parse the JSON dataset let employees = match json.parse_list(employee_json, Employee) { Ok(emps) -> emps - Err(e) -> panic("Failed to parse employees: {e.message()}") + Err(e) -> panic("Failed to parse employees: {Error.message(e)}") } println("=== JSON Data Pipeline ===\n") -- 1. Group by department diff --git a/tests/golden/repros/test_arch/run_ex_kvstore.silt b/tests/golden/repros/test_arch/run_ex_kvstore.silt index d6438ca33..44c95e4b1 100644 --- a/tests/golden/repros/test_arch/run_ex_kvstore.silt +++ b/tests/golden/repros/test_arch/run_ex_kvstore.silt @@ -85,7 +85,7 @@ fn handle_save(store) { let json_str = json.stringify(store) match io.write_file(db_path, json_str) { Ok(_) -> println("OK - saved {map.length(store)} entries to {db_path}") - Err(e) -> println("Error saving: {e.message()}") + Err(e) -> println("Error saving: {Error.message(e)}") } store } @@ -93,7 +93,7 @@ fn handle_save(store) { fn handle_load() { match io.read_file(db_path) { Err(e) -> { - println("Error loading: {e.message()}") + println("Error loading: {Error.message(e)}") println("Starting with empty store.") #{} } @@ -104,7 +104,7 @@ fn handle_load() { loaded } Err(e) -> { - println("Error parsing JSON: {e.message()}") + println("Error parsing JSON: {Error.message(e)}") println("Starting with empty store.") #{} } diff --git a/tests/golden/repros/test_arch/run_ex_link_checker.silt b/tests/golden/repros/test_arch/run_ex_link_checker.silt index 67081dc02..396f5a504 100644 --- a/tests/golden/repros/test_arch/run_ex_link_checker.silt +++ b/tests/golden/repros/test_arch/run_ex_link_checker.silt @@ -24,7 +24,7 @@ fn main() { let content = match io.read_file(file_path) { Ok(c) -> c Err(e) -> { - println("Error reading file: {e.message()}") + println("Error reading file: {Error.message(e)}") return panic("Cannot continue without file") } } diff --git a/tests/golden/repros/test_arch/run_ex_pipeline.silt b/tests/golden/repros/test_arch/run_ex_pipeline.silt index 694ba236c..310b78862 100644 --- a/tests/golden/repros/test_arch/run_ex_pipeline.silt +++ b/tests/golden/repros/test_arch/run_ex_pipeline.silt @@ -160,7 +160,7 @@ fn main() { -- Read the log file; `return` in an Err arm bails out of main. let content = match io.read_file("examples/log.txt") { Ok(c) -> c - Err(e) -> return println("Error reading log file: {e.message()}") + Err(e) -> return println("Error reading log file: {Error.message(e)}") } let lines = content |> string.split("\n") diff --git a/tests/golden/repros/test_arch/run_ex_state_machine.silt b/tests/golden/repros/test_arch/run_ex_state_machine.silt index bbb0968d4..f3361bcf5 100644 --- a/tests/golden/repros/test_arch/run_ex_state_machine.silt +++ b/tests/golden/repros/test_arch/run_ex_state_machine.silt @@ -52,7 +52,7 @@ trait Display for Event { -- Print a labeled displayable value (uses where clause) fn print_labeled(label: String, value: a) where a: Display { - println("{label}: {value.display()}") + println("{label}: {value}") } -- Print a list of displayable items with a header (uses where clause) @@ -60,7 +60,7 @@ fn print_labeled(label: String, value: a) where a: Display { fn print_items(header: String, items: List(a)) where a: Display { println(header) items - |> list.each { item -> println(" - {item.display()}") } + |> list.each { item -> println(" - {item}") } } -- Look up item info from inventory; returns (quantity, price) or None @@ -156,7 +156,7 @@ fn run_machine(events, initial_state, initial_inventory) { _ -> (state2, inventory2) } let (new_state, message, new_inv) = transition(state3, event, inventory3) - let new_log = list.append(log2, (step2, event.display(), state3, new_state, message)) + let new_log = list.append(log2, (step2, "{event}", state3, new_state, message)) (new_state, new_inv, step2 + 1, new_log) } -- If we're in Dispensing state, auto-resolve it first @@ -192,7 +192,7 @@ fn main() { _ -> "{step}" } println("[{step_str}] Event: {event_str}") - println(" {old_state.display()} -> {new_state.display()}") + println(" {old_state} -> {new_state}") println(" >> {message}") println("") } diff --git a/tests/golden/repros/test_arch/run_ex_time_demo.silt b/tests/golden/repros/test_arch/run_ex_time_demo.silt index 1f880945a..8ac405082 100644 --- a/tests/golden/repros/test_arch/run_ex_time_demo.silt +++ b/tests/golden/repros/test_arch/run_ex_time_demo.silt @@ -7,31 +7,31 @@ fn main() { let date = time.date(2024, 3, 15) match date { Ok(d) -> println("date: {d}") - Err(e) -> println("date error: {e.message()}") + Err(e) -> println("date error: {Error.message(e)}") } let bad_date = time.date(2024, 13, 1) match bad_date { Ok(d) -> println("bad date: {d}") - Err(e) -> println("bad date: {e.message()}") + Err(e) -> println("bad date: {Error.message(e)}") } let t = time.time(14, 30, 0) match t { Ok(tm) -> println("time: {tm}") - Err(e) -> println("time error: {e.message()}") + Err(e) -> println("time error: {Error.message(e)}") } let bad_time = time.time(25, 0, 0) match bad_time { Ok(tm) -> println("bad time: {tm}") - Err(e) -> println("bad time: {e.message()}") + Err(e) -> println("bad time: {Error.message(e)}") } -- Compose date + time into datetime let d = match time.date(2024, 6, 15) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let tod = match time.time(9, 30, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt = time.datetime(d, tod) println("datetime: {dt}") @@ -43,11 +43,11 @@ fn main() { -- ── Formatting ────────────────────────────────────────────────────── let dt2_date = match time.date(2024, 12, 25) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let dt2_time = match time.time(18, 0, 0) { Ok(t) -> t - Err(e) -> panic("time error: {e.message()}") + Err(e) -> panic("time error: {Error.message(e)}") } let dt2 = time.datetime(dt2_date, dt2_time) println("formatted: {dt2 @@ -58,17 +58,17 @@ fn main() { let parsed = time.parse("2024-07-04 12:00:00", "%Y-%m-%d %H:%M:%S") match parsed { Ok(dt) -> println("parsed: {dt}") - Err(e) -> println("parse error: {e.message()}") + Err(e) -> println("parse error: {Error.message(e)}") } let parsed_date = time.parse_date("2024-07-04", "%Y-%m-%d") match parsed_date { Ok(d) -> println("parsed date: {d}") - Err(e) -> println("parse date error: {e.message()}") + Err(e) -> println("parse date error: {Error.message(e)}") } let bad_parse = time.parse("not-a-date", "%Y-%m-%d %H:%M:%S") match bad_parse { Ok(dt) -> println("bad parse: {dt}") - Err(e) -> println("bad parse: {e.message()}") + Err(e) -> println("bad parse: {Error.message(e)}") } -- ── Date arithmetic ───────────────────────────────────────────────── let future = today @@ -80,14 +80,14 @@ fn main() { -- Month arithmetic with end-of-month clamping let jan31 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let feb_result = jan31 |> time.add_months(1) println("Jan 31 + 1 month = {feb_result}") let mar31 = match time.date(2024, 3, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let prev = mar31 |> time.add_months(-1) @@ -123,11 +123,11 @@ fn main() { println("today is: {weekday}") let d_start = match time.date(2024, 1, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d_end = match time.date(2024, 12, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let days = time.days_between(d_start, d_end) println("days in 2024: {days}") @@ -139,11 +139,11 @@ fn main() { -- ── Comparison ────────────────────────────────────────────────────── let d1 = match time.date(2024, 1, 31) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } let d2 = match time.date(2024, 2, 1) { Ok(d) -> d - Err(e) -> panic("date error: {e.message()}") + Err(e) -> panic("date error: {Error.message(e)}") } println("Jan 31 < Feb 1: {d1 < d2}") println("Feb 1 > Jan 31: {d2 > d1}") diff --git a/tests/golden/repros/test_arch/run_ex_todo.silt b/tests/golden/repros/test_arch/run_ex_todo.silt index 5f2fbf48e..d3e9b0b4a 100644 --- a/tests/golden/repros/test_arch/run_ex_todo.silt +++ b/tests/golden/repros/test_arch/run_ex_todo.silt @@ -62,7 +62,7 @@ fn save_todos(todos, path) { let content = json.stringify(todos) match io.write_file(path, content) { Ok(_) -> println(" Saved {list.length(todos)} todo(s) to {path}") - Err(e) -> println(" Error saving: {e.message()}") + Err(e) -> println(" Error saving: {Error.message(e)}") } } @@ -79,13 +79,13 @@ fn load_todos(path) { todos } Err(e) -> { - println(" Error parsing: {e.message()}") + println(" Error parsing: {Error.message(e)}") [] } } } Err(e) -> { - println(" Error loading: {e.message()}") + println(" Error loading: {Error.message(e)}") [] } } diff --git a/tests/golden/repros/test_arch/run_ex_trait_zoo.silt b/tests/golden/repros/test_arch/run_ex_trait_zoo.silt index 3a9a20278..8489e44fa 100644 --- a/tests/golden/repros/test_arch/run_ex_trait_zoo.silt +++ b/tests/golden/repros/test_arch/run_ex_trait_zoo.silt @@ -53,7 +53,7 @@ trait Display for Color { trait Display for Styled { fn display(self) -> String { match self { - Styled(shape, color) -> "{shape.display()} in {color.display()}" + Styled(shape, color) -> "{shape} in {color}" } } } @@ -98,7 +98,7 @@ trait Perimeter for Shape { -- Generic function with where clause fn describe(item: a) where a: Display { - item.display() + "{item}" } -- Format a float to 4 decimal places diff --git a/tests/golden/repros/test_arch/run_ex_traits.silt b/tests/golden/repros/test_arch/run_ex_traits.silt index 28b81e689..2973ab18e 100644 --- a/tests/golden/repros/test_arch/run_ex_traits.silt +++ b/tests/golden/repros/test_arch/run_ex_traits.silt @@ -26,7 +26,7 @@ fn main() { let shapes = [Circle(5.0), Rect(3.0, 4.0), Circle(1.0)] println("-- Shapes --") shapes - |> list.each { s -> println("{s.display()} -> area = {area(s)}") } + |> list.each { s -> println("{s} -> area = {area(s)}") } let total = shapes |> list.map { s -> area(s) } |> list.fold(0.0) { acc, a -> acc + a } diff --git a/tests/golden/repros/type_soundness/a6.silt b/tests/golden/repros/type_soundness/a6.silt index 8785404d5..27fe09665 100644 --- a/tests/golden/repros/type_soundness/a6.silt +++ b/tests/golden/repros/type_soundness/a6.silt @@ -4,7 +4,7 @@ trait Sz { fn sz(self) -> Int } type P { n: Int } trait Sz for P { fn sz(self) -> String { "big" } } trait Sz for Int { fn sz(self) { "unannotated string" } } -fn total(x: a, y: a) -> Int where a: Sz { x.sz() + y.sz() } +fn total(x: a, y: a) -> Int where a: Sz { Sz.sz(x) + Sz.sz(y) } fn main() { println(total(1, 2)) } diff --git a/tests/golden/repros/type_soundness/a7.silt b/tests/golden/repros/type_soundness/a7.silt index 25d51882f..f637d7dec 100644 --- a/tests/golden/repros/type_soundness/a7.silt +++ b/tests/golden/repros/type_soundness/a7.silt @@ -1,7 +1,7 @@ -- verdict: same trait Sz { fn sz(self) -> Int } trait Sz for Int { fn sz(self) { "unannotated string" } } -fn total(x: a, y: a) -> Int where a: Sz { x.sz() + y.sz() } +fn total(x: a, y: a) -> Int where a: Sz { Sz.sz(x) + Sz.sz(y) } fn main() { println(total(1, 2)) } diff --git a/tests/golden/repros/type_soundness/a8.silt b/tests/golden/repros/type_soundness/a8.silt index 0ecd29a13..489e12b4c 100644 --- a/tests/golden/repros/type_soundness/a8.silt +++ b/tests/golden/repros/type_soundness/a8.silt @@ -2,6 +2,6 @@ trait Mk { fn mk(self, other) -> Self } trait Mk for Int { fn mk(self, other) { other } } fn main() { - let n: Int = 1.mk("not int") + let n: Int = Mk.mk(1, "not int") println(n + 1) } diff --git a/tests/golden/repros/type_soundness/a9.silt b/tests/golden/repros/type_soundness/a9.silt index f6380f7d0..5464efceb 100644 --- a/tests/golden/repros/type_soundness/a9.silt +++ b/tests/golden/repros/type_soundness/a9.silt @@ -1,7 +1,7 @@ -- verdict: same trait Conv(b) { fn conv(self) -> b } trait Conv(Int) for String { fn conv(self) -> Int { 0 } } -fn into(x: a, type b) -> b where a: Conv(b) { x.conv() } +fn into(x: a, type b) -> b where a: Conv(b) { Conv.conv(x) } fn main() { let s: String = into("42", String) println(s) diff --git a/tests/golden/repros/type_soundness/al1.silt b/tests/golden/repros/type_soundness/al1.silt index 920c8c09e..e6040a0e9 100644 --- a/tests/golden/repros/type_soundness/al1.silt +++ b/tests/golden/repros/type_soundness/al1.silt @@ -9,7 +9,7 @@ fn f(p: Pairs(Int)) -> Int { match p { } } fn main() { let m: Meters = 5 - println(m.greet()) - println(5.greet()) + println(Greet.greet(m)) + println(Greet.greet(5)) println(f([(1, 2)])) } diff --git a/tests/golden/repros/type_soundness/al2.silt b/tests/golden/repros/type_soundness/al2.silt index c358604e9..deec7ad97 100644 --- a/tests/golden/repros/type_soundness/al2.silt +++ b/tests/golden/repros/type_soundness/al2.silt @@ -5,5 +5,5 @@ trait Greet { fn greet(self) -> String } trait Greet for Meters { fn greet(self) -> String { "m" } } trait Greet for Int { fn greet(self) -> String { "i" } } fn main() { - println(5.greet()) + println(Greet.greet(5)) } diff --git a/tests/golden/repros/type_soundness/al3.silt b/tests/golden/repros/type_soundness/al3.silt index a0ff187c5..ca3cd520e 100644 --- a/tests/golden/repros/type_soundness/al3.silt +++ b/tests/golden/repros/type_soundness/al3.silt @@ -6,11 +6,11 @@ trait Greet for Float { fn greet(self) -> String { "float" } } trait Greet for ExtFloat { fn greet(self) -> String { "ext" } } fn g(x) { x / 2.0 } fn main() { - println((1..3).greet()) + println(Greet.greet(1..3)) let a = 1.0 / 2.0 - println(a.greet()) + println(Greet.greet(a)) let b = 1.0 + 2.0 - println(b.greet()) + println(Greet.greet(b)) let c = g(4.0) - println(c.greet()) + println(Greet.greet(c)) } diff --git a/tests/golden/repros/type_soundness/al4.silt b/tests/golden/repros/type_soundness/al4.silt index fa02f2dab..1e565eb1d 100644 --- a/tests/golden/repros/type_soundness/al4.silt +++ b/tests/golden/repros/type_soundness/al4.silt @@ -5,5 +5,5 @@ trait Greet for ExtFloat { fn greet(self) -> String { "ext" } } fn g(x) { x / 2.0 } fn main() { let c = g(4.0) - println(c.greet()) + println(Greet.greet(c)) } diff --git a/tests/golden/repros/type_soundness/an3.silt b/tests/golden/repros/type_soundness/an3.silt index bb26edbce..f2c854e87 100644 --- a/tests/golden/repros/type_soundness/an3.silt +++ b/tests/golden/repros/type_soundness/an3.silt @@ -3,6 +3,6 @@ type Box(a) { Box(a) } trait Get { fn get(self) -> Int } trait Get for Box { fn get(self) -> Int { match self { Box(v) -> v } } } fn main() { - println(Box(1).get()) - println(Box("s").get() + 1) + println(Get.get(Box(1))) + println(Get.get(Box("s")) + 1) } diff --git a/tests/golden/repros/type_soundness/c2.silt b/tests/golden/repros/type_soundness/c2.silt index 0a720b8f1..0372b3900 100644 --- a/tests/golden/repros/type_soundness/c2.silt +++ b/tests/golden/repros/type_soundness/c2.silt @@ -1,6 +1,6 @@ -- verdict: same -- method call on unconstrained type var -fn show(x) { x.display() } +fn show(x) { "{x}" } fn main() { let f = fn(x) { x + 1 } println(show(1)) diff --git a/tests/golden/repros/type_soundness/c3.silt b/tests/golden/repros/type_soundness/c3.silt index fa9732ec2..2e677edc8 100644 --- a/tests/golden/repros/type_soundness/c3.silt +++ b/tests/golden/repros/type_soundness/c3.silt @@ -2,7 +2,7 @@ -- user trait method on unconstrained tyvar trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn g(x) { x.greet() } +fn g(x) { Greet.greet(x) } fn main() { println(g(1)) println(g("s")) diff --git a/tests/golden/repros/type_soundness/d1.silt b/tests/golden/repros/type_soundness/d1.silt index 8a3f65a24..ddb82c749 100644 --- a/tests/golden/repros/type_soundness/d1.silt +++ b/tests/golden/repros/type_soundness/d1.silt @@ -3,7 +3,7 @@ trait Same { fn same(self) -> Self } trait Same for String { fn same(self) -> Self { self } } -fn coerce(x) { x.same() } +fn coerce(x) { Same.same(x) } fn main() { let n: Int = coerce("not an int") diff --git a/tests/golden/repros/type_soundness/d3.silt b/tests/golden/repros/type_soundness/d3.silt index e7d262b7d..f80d18d33 100644 --- a/tests/golden/repros/type_soundness/d3.silt +++ b/tests/golden/repros/type_soundness/d3.silt @@ -4,7 +4,7 @@ import map trait Same { fn same(self) -> Self } trait Same for String { fn same(self) -> Self { self } } -fn coerce(x) { x.same() } +fn coerce(x) { Same.same(x) } fn main() { let r: {name: String, age: Int} = coerce("zzz") diff --git a/tests/golden/repros/type_soundness/d5.silt b/tests/golden/repros/type_soundness/d5.silt index 0ec26dfd2..668d5f34c 100644 --- a/tests/golden/repros/type_soundness/d5.silt +++ b/tests/golden/repros/type_soundness/d5.silt @@ -1,5 +1,5 @@ -- verdict: same -fn f(x) { x.display() } +fn f(x) { "{x}" } fn main() { let g = fn(x) { x } println(g.display()) diff --git a/tests/golden/repros/type_soundness/d6.silt b/tests/golden/repros/type_soundness/d6.silt index 3167645d2..fd4e685ad 100644 --- a/tests/golden/repros/type_soundness/d6.silt +++ b/tests/golden/repros/type_soundness/d6.silt @@ -2,7 +2,7 @@ import list trait Same { fn same(self) -> Self } trait Same for String { fn same(self) -> Self { self } } -fn coerce(x) { x.same() } +fn coerce(x) { Same.same(x) } fn main() { let r: {name: String, age: Int} = coerce("zzz") println(r.age) diff --git a/tests/golden/repros/type_soundness/d7.silt b/tests/golden/repros/type_soundness/d7.silt index 7d25b645f..540ea1ea2 100644 --- a/tests/golden/repros/type_soundness/d7.silt +++ b/tests/golden/repros/type_soundness/d7.silt @@ -1,7 +1,7 @@ -- verdict: same trait Same { fn same(self) -> Self } trait Same for String { fn same(self) -> Self { self } } -fn coerce(x) { x.same() } +fn coerce(x) { Same.same(x) } fn main() { let f: Fn(Int) -> Int = coerce("callme") println(f(1)) diff --git a/tests/golden/repros/type_soundness/d8.silt b/tests/golden/repros/type_soundness/d8.silt index 32f1e2b96..62f9d95c3 100644 --- a/tests/golden/repros/type_soundness/d8.silt +++ b/tests/golden/repros/type_soundness/d8.silt @@ -1,7 +1,7 @@ -- verdict: same trait Same { fn same(self) -> Self } trait Same for String { fn same(self) -> Self { self } } -fn coerce(x) { x.same() } +fn coerce(x) { Same.same(x) } type Shape { Circle(Int), Sq(Int) } fn main() { let s: Shape = coerce("callme") diff --git a/tests/golden/repros/type_soundness/d9.silt b/tests/golden/repros/type_soundness/d9.silt index 030819769..1120c6a90 100644 --- a/tests/golden/repros/type_soundness/d9.silt +++ b/tests/golden/repros/type_soundness/d9.silt @@ -1,7 +1,7 @@ -- verdict: same trait Same { fn same(self) -> Self } trait Same for Int { fn same(self) -> Self { self } } -fn coerce(x) { x.same() } +fn coerce(x) { Same.same(x) } type Shape { Circle(Int), Sq(Int) } fn main() { let b: Bool = coerce(7) diff --git a/tests/golden/repros/type_soundness/e10.silt b/tests/golden/repros/type_soundness/e10.silt index 364a8b1f4..448d3cc91 100644 --- a/tests/golden/repros/type_soundness/e10.silt +++ b/tests/golden/repros/type_soundness/e10.silt @@ -3,5 +3,5 @@ import list type P { v: Int } fn main() { let ps = [P { v: 1 }] - println(list.map(ps) { p -> p.display() }) + println(list.map(ps) { p -> "{p}" }) } diff --git a/tests/golden/repros/type_soundness/e11.silt b/tests/golden/repros/type_soundness/e11.silt index 652cd8071..14b0f3b09 100644 --- a/tests/golden/repros/type_soundness/e11.silt +++ b/tests/golden/repros/type_soundness/e11.silt @@ -6,5 +6,5 @@ trait Greet for P { fn greet(self) -> String { "p" } } fn main() { let ps = [P { v: 1 }] -- pipe form - ps |> list.map { p -> p.greet() } |> println + ps |> list.map { p -> Greet.greet(p) } |> println } diff --git a/tests/golden/repros/type_soundness/e6.silt b/tests/golden/repros/type_soundness/e6.silt index 14a039686..81f099afd 100644 --- a/tests/golden/repros/type_soundness/e6.silt +++ b/tests/golden/repros/type_soundness/e6.silt @@ -2,6 +2,6 @@ import list fn main() { let xs = [1, 2, 3] - let ys = list.map(xs) { x -> x.display() } + let ys = list.map(xs) { x -> "{x}" } println(ys) } diff --git a/tests/golden/repros/type_soundness/e8.silt b/tests/golden/repros/type_soundness/e8.silt index 2407998dc..471ebf1f5 100644 --- a/tests/golden/repros/type_soundness/e8.silt +++ b/tests/golden/repros/type_soundness/e8.silt @@ -7,9 +7,9 @@ trait Greet for Int { fn greet(self) -> String { "i" } } trait Greet for List(a) { fn greet(self) -> String { "l" } } fn main() { let ps = [P { v: 1 }] - println(list.map(ps) { p -> p.greet() }) - println(list.map([1]) { p -> p.greet() }) - println(list.map([[1]]) { p -> p.greet() }) - println(list.map([(1, 2)]) { p -> p.display() }) - println(list.map(["a"]) { p -> p.display() }) + println(list.map(ps) { p -> Greet.greet(p) }) + println(list.map([1]) { p -> Greet.greet(p) }) + println(list.map([[1]]) { p -> Greet.greet(p) }) + println(list.map([(1, 2)]) { p -> "{p}" }) + println(list.map(["a"]) { p -> "{p}" }) } diff --git a/tests/golden/repros/type_soundness/e9.silt b/tests/golden/repros/type_soundness/e9.silt index 2c4b551a1..f134ee088 100644 --- a/tests/golden/repros/type_soundness/e9.silt +++ b/tests/golden/repros/type_soundness/e9.silt @@ -4,6 +4,6 @@ type Shape { Circle(Int), Sq(Int) } trait Greet { fn greet(self) -> String } trait Greet for Shape { fn greet(self) -> String { "shape" } } fn main() { - println(list.map([Circle(1)]) { p -> p.greet() }) - println(list.map([Circle(1)]) { p -> p.display() }) + println(list.map([Circle(1)]) { p -> Greet.greet(p) }) + println(list.map([Circle(1)]) { p -> "{p}" }) } diff --git a/tests/golden/repros/type_soundness/f8.silt b/tests/golden/repros/type_soundness/f8.silt index 4b89663c4..f717bc55e 100644 --- a/tests/golden/repros/type_soundness/f8.silt +++ b/tests/golden/repros/type_soundness/f8.silt @@ -1,7 +1,7 @@ -- verdict: same -- where clause on a tyvar that gets unified to concrete trait Greet { fn greet(self) -> String } -fn f(x: a) -> String where a: Greet { x.greet() + string.from(x + 1) } +fn f(x: a) -> String where a: Greet { Greet.greet(x) + string.from(x + 1) } fn main() { println(f(2)) } diff --git a/tests/golden/repros/type_soundness/r4.silt b/tests/golden/repros/type_soundness/r4.silt index af9c29c5d..765adb851 100644 --- a/tests/golden/repros/type_soundness/r4.silt +++ b/tests/golden/repros/type_soundness/r4.silt @@ -2,7 +2,7 @@ type P { name: String, age: Int } trait Greet { fn greet(self) -> String } trait Greet for P { fn greet(self) -> String { "I am {self.name}" } } -fn takes_p(p: P) -> String { p.greet() } +fn takes_p(p: P) -> String { Greet.greet(p) } fn show_p(p: P) -> String { "{p}" } fn main() { println(takes_p(P {name: "x", age: 3})) diff --git a/tests/golden/repros/type_soundness/w1.silt b/tests/golden/repros/type_soundness/w1.silt index ed6c59e10..f32aaf6ce 100644 --- a/tests/golden/repros/type_soundness/w1.silt +++ b/tests/golden/repros/type_soundness/w1.silt @@ -2,7 +2,7 @@ import list trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } -- through higher-order function fn apply(f, x) { f(x) } diff --git a/tests/golden/repros/type_soundness/w10.silt b/tests/golden/repros/type_soundness/w10.silt index b9cbfa7b9..87c760c8b 100644 --- a/tests/golden/repros/type_soundness/w10.silt +++ b/tests/golden/repros/type_soundness/w10.silt @@ -2,7 +2,7 @@ import list trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { println(list.map(["a", "b"], fn(x) { hello(x) })) } diff --git a/tests/golden/repros/type_soundness/w11.silt b/tests/golden/repros/type_soundness/w11.silt index 3eb57fb2a..3fea5c1b8 100644 --- a/tests/golden/repros/type_soundness/w11.silt +++ b/tests/golden/repros/type_soundness/w11.silt @@ -2,7 +2,7 @@ import list trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { let f: Fn(String) -> String = hello println(f("x")) diff --git a/tests/golden/repros/type_soundness/w2.silt b/tests/golden/repros/type_soundness/w2.silt index 1592b7636..2ee4f380c 100644 --- a/tests/golden/repros/type_soundness/w2.silt +++ b/tests/golden/repros/type_soundness/w2.silt @@ -2,7 +2,7 @@ import list trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { println(list.map(["a", "b"], hello)) } diff --git a/tests/golden/repros/type_soundness/w3.silt b/tests/golden/repros/type_soundness/w3.silt index 1d2e2b793..27a916a90 100644 --- a/tests/golden/repros/type_soundness/w3.silt +++ b/tests/golden/repros/type_soundness/w3.silt @@ -1,7 +1,7 @@ -- verdict: same trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } type Ops(a) { run: Fn(a) -> String } fn main() { let o = Ops { run: hello } diff --git a/tests/golden/repros/type_soundness/w3b.silt b/tests/golden/repros/type_soundness/w3b.silt index bb9c9ae1e..b964074cc 100644 --- a/tests/golden/repros/type_soundness/w3b.silt +++ b/tests/golden/repros/type_soundness/w3b.silt @@ -1,7 +1,7 @@ -- verdict: same trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { let t = (hello, 1) let (g, _) = t diff --git a/tests/golden/repros/type_soundness/w3c.silt b/tests/golden/repros/type_soundness/w3c.silt index ce7a181ea..44afac950 100644 --- a/tests/golden/repros/type_soundness/w3c.silt +++ b/tests/golden/repros/type_soundness/w3c.silt @@ -1,7 +1,7 @@ -- verdict: same trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { let fs = [hello] match fs { diff --git a/tests/golden/repros/type_soundness/w4.silt b/tests/golden/repros/type_soundness/w4.silt index bbed81b7a..4591e272a 100644 --- a/tests/golden/repros/type_soundness/w4.silt +++ b/tests/golden/repros/type_soundness/w4.silt @@ -1,7 +1,7 @@ -- verdict: same trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn wrap(x) { hello(x) } fn wrap2(x) { wrap(x) } fn main() { diff --git a/tests/golden/repros/type_soundness/w5.silt b/tests/golden/repros/type_soundness/w5.silt index 2980ae6f2..ea9d4ac01 100644 --- a/tests/golden/repros/type_soundness/w5.silt +++ b/tests/golden/repros/type_soundness/w5.silt @@ -1,7 +1,7 @@ -- verdict: same trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { let h = hello println(h("s")) diff --git a/tests/golden/repros/type_soundness/w6.silt b/tests/golden/repros/type_soundness/w6.silt index db4acf92f..515157064 100644 --- a/tests/golden/repros/type_soundness/w6.silt +++ b/tests/golden/repros/type_soundness/w6.silt @@ -1,7 +1,7 @@ -- verdict: same trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn wrap(x: b) -> String { hello(x) } fn main() { println(wrap("s")) diff --git a/tests/golden/repros/type_soundness/w7.silt b/tests/golden/repros/type_soundness/w7.silt index 58f89f8f5..0a34b7b45 100644 --- a/tests/golden/repros/type_soundness/w7.silt +++ b/tests/golden/repros/type_soundness/w7.silt @@ -1,7 +1,7 @@ -- verdict: same trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn wrap(x) { hello(x) } fn wrap2(x) { wrap(x) } fn main() { diff --git a/tests/golden/repros/type_soundness/w8.silt b/tests/golden/repros/type_soundness/w8.silt index af69af7eb..02d6b56d6 100644 --- a/tests/golden/repros/type_soundness/w8.silt +++ b/tests/golden/repros/type_soundness/w8.silt @@ -1,7 +1,7 @@ -- verdict: same trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn wrap(x) { hello(x) } fn main() { println(wrap(1)) diff --git a/tests/golden/repros/type_soundness/xr2.silt b/tests/golden/repros/type_soundness/xr2.silt index 29de05d0d..f49177737 100644 --- a/tests/golden/repros/type_soundness/xr2.silt +++ b/tests/golden/repros/type_soundness/xr2.silt @@ -12,11 +12,11 @@ fn int_cmp(a: Int, b: Int) -> Int { match { fn main() { let a = P { v: 1 } let b = P { v: 2 } - println(a.equal(b)) println(a == b) - println(a.compare(b)) + println(a == b) + println(Compare.compare(a, b)) println(a < b) - println(a.display()) + println("{a}") println("{a}") println(a) println(list.sort([a, b])) diff --git a/tests/golden/repros/type_soundness/z1.silt b/tests/golden/repros/type_soundness/z1.silt index f3746a7ab..180db1df9 100644 --- a/tests/golden/repros/type_soundness/z1.silt +++ b/tests/golden/repros/type_soundness/z1.silt @@ -2,7 +2,7 @@ import channel type Box(a) { Box(a) } fn show(x) { "{x}" } -fn show2(x) { x.display() } +fn show2(x) { "{x}" } fn pr(x) { println(x) } fn main() { let f = fn(x) { x } diff --git a/tests/golden/repros/type_soundness/z2.silt b/tests/golden/repros/type_soundness/z2.silt index a0404175d..033f9ae5e 100644 --- a/tests/golden/repros/type_soundness/z2.silt +++ b/tests/golden/repros/type_soundness/z2.silt @@ -1,7 +1,7 @@ -- verdict: same type Box(a) { Box(a) } fn show(x) { "{x}" } -fn show2(x) { x.display() } +fn show2(x) { "{x}" } fn pr(x) { println(x) } fn main() { let f = fn(x) { x } diff --git a/tests/golden/repros/type_soundness/z3.silt b/tests/golden/repros/type_soundness/z3.silt index 01b385bfc..0fbf7d178 100644 --- a/tests/golden/repros/type_soundness/z3.silt +++ b/tests/golden/repros/type_soundness/z3.silt @@ -1,7 +1,7 @@ -- verdict: same type Box(a) { Box(a) } fn show(x) { "{x}" } -fn show2(x) { x.display() } +fn show2(x) { "{x}" } fn pr(x) { println(x) } fn main() { let f = fn(x) { x } diff --git a/tests/golden/repros/typechecker_arch/alias1_main/a.silt b/tests/golden/repros/typechecker_arch/alias1_main/a.silt index 0dd499815..cde98c207 100644 --- a/tests/golden/repros/typechecker_arch/alias1_main/a.silt +++ b/tests/golden/repros/typechecker_arch/alias1_main/a.silt @@ -1,4 +1,4 @@ type Id = Int trait Show2 { fn show2(self) -> String } trait Show2 for Id { fn show2(self) -> String { "int-id" } } -pub fn f(x: Int) -> String { x.show2() } +pub fn f(x: Int) -> String { Show2.show2(x) } diff --git a/tests/golden/repros/typechecker_arch/alias1_main_only_a/a.silt b/tests/golden/repros/typechecker_arch/alias1_main_only_a/a.silt index 0dd499815..cde98c207 100644 --- a/tests/golden/repros/typechecker_arch/alias1_main_only_a/a.silt +++ b/tests/golden/repros/typechecker_arch/alias1_main_only_a/a.silt @@ -1,4 +1,4 @@ type Id = Int trait Show2 { fn show2(self) -> String } trait Show2 for Id { fn show2(self) -> String { "int-id" } } -pub fn f(x: Int) -> String { x.show2() } +pub fn f(x: Int) -> String { Show2.show2(x) } diff --git a/tests/golden/repros/typechecker_arch/cv2_ver.silt b/tests/golden/repros/typechecker_arch/cv2_ver.silt index 740f19391..f21876c0e 100644 --- a/tests/golden/repros/typechecker_arch/cv2_ver.silt +++ b/tests/golden/repros/typechecker_arch/cv2_ver.silt @@ -4,5 +4,5 @@ fn main() { let a = Ver { major: 1, build: 9 } let b = Ver { major: 2, build: 0 } println(a < b) - println(a.compare(b)) + println(Compare.compare(a, b)) } diff --git a/tests/golden/repros/typechecker_arch/derive_d1.silt b/tests/golden/repros/typechecker_arch/derive_d1.silt index df922dd37..3fd35b50e 100644 --- a/tests/golden/repros/typechecker_arch/derive_d1.silt +++ b/tests/golden/repros/typechecker_arch/derive_d1.silt @@ -6,18 +6,18 @@ type G(a) { Wrap(a), Nil } fn main() { let p = P { x: 1, y: "s" } let b = B { v: 1, w: 2 } - println(p.display()) - println(b.display()) - println(A(1).display()) - println(Wrap(1).display()) + println("{p}") + println("{b}") + println("{A(1)}") + println("{Wrap(1)}") println("{p} {b}") - println(p.equal(p)) - println(b.equal(b)) - println(p.compare(P { x: 2, y: "a" })) - println(b.compare(B { v: 2, w: 0 })) - println(p.hash() == p.hash()) - println(b.hash() == b.hash()) + println(p == p) + println(b == b) + println(Compare.compare(p, P { x: 2, y: "a" })) + println(Compare.compare(b, B { v: 2, w: 0 })) + println(Hash.hash(p) == Hash.hash(p)) + println(Hash.hash(b) == Hash.hash(b)) println(p < P { x: 2, y: "a" }) - println(Wrap(1).compare(Nil)) - println(A(1).compare(C)) + println(Compare.compare(Wrap(1), Nil)) + println(Compare.compare(A(1), C)) } diff --git a/tests/golden/repros/typechecker_arch/derive_d2.silt b/tests/golden/repros/typechecker_arch/derive_d2.silt index f555de5e0..93ca16a8e 100644 --- a/tests/golden/repros/typechecker_arch/derive_d2.silt +++ b/tests/golden/repros/typechecker_arch/derive_d2.silt @@ -1,4 +1,5 @@ -- verdict: same +import string type P { x: Int, y: String } type B(a) { v: a, w: Int } type E { A(Int, String), C } @@ -10,16 +11,16 @@ fn main() { let p = P { x: 1, y: "s" } let b = B { v: 1, w: 2 } println(p) - println(p.display()) + println("{p}") println("{p}") println(b) - println(b.display()) + println("{b}") println("{b}") println(Wrap(1, "q")) - println(Wrap(1, "q").display()) + println(string.from(Wrap(1, "q"))) println("{Wrap(1, "q")}") println(A(1, "z")) - println(A(1, "z").display()) + println(string.from(A(1, "z"))) println("{A(1, "z")}") println([A(1, "z")]) println([p]) diff --git a/tests/golden/repros/typechecker_arch/derive_d3.silt b/tests/golden/repros/typechecker_arch/derive_d3.silt index c82d6b578..26f723b63 100644 --- a/tests/golden/repros/typechecker_arch/derive_d3.silt +++ b/tests/golden/repros/typechecker_arch/derive_d3.silt @@ -5,7 +5,7 @@ trait Display for Temp { } fn main() { let t = Temp { degrees: 21 } - println(t.display()) + println("{t}") println("{t}") println(t) let s = "now: {t}" diff --git a/tests/golden/repros/typechecker_arch/derive_d4.silt b/tests/golden/repros/typechecker_arch/derive_d4.silt index 07894cfc3..4d45fdc4f 100644 --- a/tests/golden/repros/typechecker_arch/derive_d4.silt +++ b/tests/golden/repros/typechecker_arch/derive_d4.silt @@ -11,9 +11,9 @@ trait Compare for Name { fn main() { let a = Name { s: "a" } let b = Name { s: "b" } - println(a.equal(b)) println(a == b) - println(a.compare(b)) + println(a == b) + println(Compare.compare(a, b)) println(a < b) println(list.sort([b, a])) println(set.length(set.from_list([a, b]))) diff --git a/tests/golden/repros/typechecker_arch/mm3_main/a.silt b/tests/golden/repros/typechecker_arch/mm3_main/a.silt index c46ec1238..2e4b78d05 100644 --- a/tests/golden/repros/typechecker_arch/mm3_main/a.silt +++ b/tests/golden/repros/typechecker_arch/mm3_main/a.silt @@ -1,4 +1,4 @@ trait Speak { fn speak(self) -> String } pub type Dog { name: String } trait Speak for Dog { fn speak(self) -> String { "woof" } } -pub fn talk(x: t) -> String where t: Speak { x.speak() } +pub fn talk(x: t) -> String where t: Speak { Speak.speak(x) } diff --git a/tests/golden/repros/typechecker_arch/mm3_main/b.silt b/tests/golden/repros/typechecker_arch/mm3_main/b.silt index b5db843ae..861ae6ea9 100644 --- a/tests/golden/repros/typechecker_arch/mm3_main/b.silt +++ b/tests/golden/repros/typechecker_arch/mm3_main/b.silt @@ -1,4 +1,4 @@ trait Speak { fn speak(self, times: Int) -> Int } pub type Cat { name: String } trait Speak for Cat { fn speak(self, times: Int) -> Int { times } } -pub fn talk(x: t) -> Int where t: Speak { x.speak(2) } +pub fn talk(x: t) -> Int where t: Speak { Speak.speak(x, 2) } diff --git a/tests/golden/repros/typechecker_arch/mm3_main2/a.silt b/tests/golden/repros/typechecker_arch/mm3_main2/a.silt index c46ec1238..2e4b78d05 100644 --- a/tests/golden/repros/typechecker_arch/mm3_main2/a.silt +++ b/tests/golden/repros/typechecker_arch/mm3_main2/a.silt @@ -1,4 +1,4 @@ trait Speak { fn speak(self) -> String } pub type Dog { name: String } trait Speak for Dog { fn speak(self) -> String { "woof" } } -pub fn talk(x: t) -> String where t: Speak { x.speak() } +pub fn talk(x: t) -> String where t: Speak { Speak.speak(x) } diff --git a/tests/golden/repros/typechecker_arch/mm3_main2/b.silt b/tests/golden/repros/typechecker_arch/mm3_main2/b.silt index b5db843ae..861ae6ea9 100644 --- a/tests/golden/repros/typechecker_arch/mm3_main2/b.silt +++ b/tests/golden/repros/typechecker_arch/mm3_main2/b.silt @@ -1,4 +1,4 @@ trait Speak { fn speak(self, times: Int) -> Int } pub type Cat { name: String } trait Speak for Cat { fn speak(self, times: Int) -> Int { times } } -pub fn talk(x: t) -> Int where t: Speak { x.speak(2) } +pub fn talk(x: t) -> Int where t: Speak { Speak.speak(x, 2) } diff --git a/tests/golden/repros/typechecker_arch/recheck_alias_impl.silt b/tests/golden/repros/typechecker_arch/recheck_alias_impl.silt index fc35bb5cf..3aa2a80a6 100644 --- a/tests/golden/repros/typechecker_arch/recheck_alias_impl.silt +++ b/tests/golden/repros/typechecker_arch/recheck_alias_impl.silt @@ -4,4 +4,4 @@ type Ints = List(Int) trait Foo for Ints { fn foo(self) -> Int { "not an int" } } -fn main() { println([1, 2].foo()) } +fn main() { println(Foo.foo([1, 2])) } diff --git a/tests/golden/repros/typechecker_arch/recheck_alias_impl_nonarrow.silt b/tests/golden/repros/typechecker_arch/recheck_alias_impl_nonarrow.silt index dc5bb5428..8f9b51e9a 100644 --- a/tests/golden/repros/typechecker_arch/recheck_alias_impl_nonarrow.silt +++ b/tests/golden/repros/typechecker_arch/recheck_alias_impl_nonarrow.silt @@ -4,4 +4,4 @@ type Ints = List(Int) trait Foo for Ints { fn foo(self) -> Int { "not an int" } } -fn main() -> () { println([1, 2].foo()) } +fn main() -> () { println(Foo.foo([1, 2])) } diff --git a/tests/golden/repros/typechecker_arch/recheck_fun_impl.silt b/tests/golden/repros/typechecker_arch/recheck_fun_impl.silt index afb370453..e93be366c 100644 --- a/tests/golden/repros/typechecker_arch/recheck_fun_impl.silt +++ b/tests/golden/repros/typechecker_arch/recheck_fun_impl.silt @@ -3,4 +3,4 @@ trait Foo { fn foo(self) -> Int } trait Foo for Fun { fn foo(self) -> Int { undefined_name + 1 } } -fn main() { println(main.foo()) } +fn main() { println(Foo.foo(main)) } diff --git a/tests/golden/repros/typechecker_arch/recheck_list_impl.silt b/tests/golden/repros/typechecker_arch/recheck_list_impl.silt index 2b5289fa3..bc51245d6 100644 --- a/tests/golden/repros/typechecker_arch/recheck_list_impl.silt +++ b/tests/golden/repros/typechecker_arch/recheck_list_impl.silt @@ -3,4 +3,4 @@ trait Foo { fn foo(self) -> Int } trait Foo for List(a) { fn foo(self) -> Int { "not an int" } } -fn main() { println([1, 2].foo()) } +fn main() { println(Foo.foo([1, 2])) } diff --git a/tests/golden/repros/typechecker_arch/t_method_value_generic_impl.silt b/tests/golden/repros/typechecker_arch/t_method_value_generic_impl.silt index 35f660feb..22a1fad19 100644 --- a/tests/golden/repros/typechecker_arch/t_method_value_generic_impl.silt +++ b/tests/golden/repros/typechecker_arch/t_method_value_generic_impl.silt @@ -2,7 +2,7 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } type Box(a) { Box(a) } -trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { Box(i) -> i.greet() } } } +trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { Box(i) -> Greet.greet(i) } } } fn main() { let b = Box(3) let m = b.greet println(m(b)) } diff --git a/tests/golden/repros/typechecker_arch/t_poly_method.silt b/tests/golden/repros/typechecker_arch/t_poly_method.silt index eaff86dc2..902507fc9 100644 --- a/tests/golden/repros/typechecker_arch/t_poly_method.silt +++ b/tests/golden/repros/typechecker_arch/t_poly_method.silt @@ -1,5 +1,5 @@ -- verdict: same -fn show(x) { x.display() } +fn show(x) { "{x}" } fn main() { let f = fn(y) { y } println(show(f) + 1) diff --git a/tests/golden/repros/typechecker_arch/t_tm_as_value.silt b/tests/golden/repros/typechecker_arch/t_tm_as_value.silt index 0d25a4019..59e9f63b7 100644 --- a/tests/golden/repros/typechecker_arch/t_tm_as_value.silt +++ b/tests/golden/repros/typechecker_arch/t_tm_as_value.silt @@ -2,6 +2,6 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Sh { fn sh(self, x: a) -> String where a: Greet } -trait Sh for Bool { fn sh(self, x: a) -> String where a: Greet { x.greet() } } +trait Sh for Bool { fn sh(self, x: a) -> String where a: Greet { Greet.greet(x) } } fn main() { let m = true.sh println(m(true, 3)) } diff --git a/tests/golden/repros/typechecker_arch/t_where_direct.silt b/tests/golden/repros/typechecker_arch/t_where_direct.silt index f50cce0da..87681aa42 100644 --- a/tests/golden/repros/typechecker_arch/t_where_direct.silt +++ b/tests/golden/repros/typechecker_arch/t_where_direct.silt @@ -1,5 +1,5 @@ -- verdict: same trait Showable { fn show(self) -> String } trait Showable for Int { fn show(self) -> String { "int" } } -fn display(x: a) -> String where a: Showable { x.show() } +fn display(x: a) -> String where a: Showable { Showable.show(x) } fn main() { println(display("text")) } diff --git a/tests/golden/repros/typechecker_arch/t_where_hof.silt b/tests/golden/repros/typechecker_arch/t_where_hof.silt index ff50ecb40..87cfe6a70 100644 --- a/tests/golden/repros/typechecker_arch/t_where_hof.silt +++ b/tests/golden/repros/typechecker_arch/t_where_hof.silt @@ -1,6 +1,6 @@ -- verdict: same trait Showable { fn show(self) -> String } trait Showable for Int { fn show(self) -> String { "int" } } -fn display(x: a) -> String where a: Showable { x.show() } +fn display(x: a) -> String where a: Showable { Showable.show(x) } fn apply(f, x) { f(x) } fn main() { println(apply(display, "text")) } diff --git a/tests/golden/repros/typechecker_arch/t_where_paren.silt b/tests/golden/repros/typechecker_arch/t_where_paren.silt index b43d9baa3..24c8887ba 100644 --- a/tests/golden/repros/typechecker_arch/t_where_paren.silt +++ b/tests/golden/repros/typechecker_arch/t_where_paren.silt @@ -1,7 +1,7 @@ -- verdict: same trait Showable { fn show(self) -> String } trait Showable for Int { fn show(self) -> String { "int" } } -fn display(x: a) -> String where a: Showable { x.show() } +fn display(x: a) -> String where a: Showable { Showable.show(x) } fn main() { let fs = [display] match fs { diff --git a/tests/golden/repros/typechecker_arch/t_where_pipe_call.silt b/tests/golden/repros/typechecker_arch/t_where_pipe_call.silt index 4ccf4e5c8..66710ec1e 100644 --- a/tests/golden/repros/typechecker_arch/t_where_pipe_call.silt +++ b/tests/golden/repros/typechecker_arch/t_where_pipe_call.silt @@ -1,5 +1,5 @@ -- verdict: same trait Showable { fn show(self) -> String } trait Showable for Int { fn show(self) -> String { "int" } } -fn display(x: a) -> String where a: Showable { x.show() } +fn display(x: a) -> String where a: Showable { Showable.show(x) } fn main() { println("text" |> display()) } diff --git a/tests/golden/repros/typechecker_arch/t_where_pipe_plain.silt b/tests/golden/repros/typechecker_arch/t_where_pipe_plain.silt index 59c164c5f..b2ffdbf28 100644 --- a/tests/golden/repros/typechecker_arch/t_where_pipe_plain.silt +++ b/tests/golden/repros/typechecker_arch/t_where_pipe_plain.silt @@ -1,5 +1,5 @@ -- verdict: same trait Showable { fn show(self) -> String } trait Showable for Int { fn show(self) -> String { "int" } } -fn display(x: a) -> String where a: Showable { x.show() } +fn display(x: a) -> String where a: Showable { Showable.show(x) } fn main() { println("text" |> display) } diff --git a/tests/golden/repros/verify/cv_cv4.silt b/tests/golden/repros/verify/cv_cv4.silt index 4cd30870b..fc9ad96e0 100644 --- a/tests/golden/repros/verify/cv_cv4.silt +++ b/tests/golden/repros/verify/cv_cv4.silt @@ -4,5 +4,5 @@ fn main() { let x = R { b: 1, a: 2 } let y = R { b: 2, a: 1 } println(x < y) - println(x.compare(y)) + println(Compare.compare(x, y)) } diff --git a/tests/golden/repros/verify/cv_cv6.silt b/tests/golden/repros/verify/cv_cv6.silt index 217890301..02919191b 100644 --- a/tests/golden/repros/verify/cv_cv6.silt +++ b/tests/golden/repros/verify/cv_cv6.silt @@ -5,11 +5,11 @@ trait Deep for Int { fn go(self) -> Int { match self { 0 -> 0 - _ -> 1 + (self - 1).go() + _ -> 1 + Deep.go(self - 1) } } } fn main() { - let t = task.spawn { -> 20.go() } + let t = task.spawn { -> Deep.go(20) } println(task.join(t)) } diff --git a/tests/golden/repros/verify/ld_ld3.silt b/tests/golden/repros/verify/ld_ld3.silt index 23bef8393..a536065a6 100644 --- a/tests/golden/repros/verify/ld_ld3.silt +++ b/tests/golden/repros/verify/ld_ld3.silt @@ -7,5 +7,5 @@ fn main() { let p = P { x: 1 } println(p) println("{p}") - println(p.display()) + println("{p}") } diff --git a/tests/golden/repros/verify/tca_tca3.silt b/tests/golden/repros/verify/tca_tca3.silt index fc35bb5cf..3aa2a80a6 100644 --- a/tests/golden/repros/verify/tca_tca3.silt +++ b/tests/golden/repros/verify/tca_tca3.silt @@ -4,4 +4,4 @@ type Ints = List(Int) trait Foo for Ints { fn foo(self) -> Int { "not an int" } } -fn main() { println([1, 2].foo()) } +fn main() { println(Foo.foo([1, 2])) } diff --git a/tests/golden/repros/verify/tca_tca3_control.silt b/tests/golden/repros/verify/tca_tca3_control.silt index 2b5289fa3..bc51245d6 100644 --- a/tests/golden/repros/verify/tca_tca3_control.silt +++ b/tests/golden/repros/verify/tca_tca3_control.silt @@ -3,4 +3,4 @@ trait Foo { fn foo(self) -> Int } trait Foo for List(a) { fn foo(self) -> Int { "not an int" } } -fn main() { println([1, 2].foo()) } +fn main() { println(Foo.foo([1, 2])) } diff --git a/tests/golden/repros/verify/tca_tca4.silt b/tests/golden/repros/verify/tca_tca4.silt index ff50ecb40..87cfe6a70 100644 --- a/tests/golden/repros/verify/tca_tca4.silt +++ b/tests/golden/repros/verify/tca_tca4.silt @@ -1,6 +1,6 @@ -- verdict: same trait Showable { fn show(self) -> String } trait Showable for Int { fn show(self) -> String { "int" } } -fn display(x: a) -> String where a: Showable { x.show() } +fn display(x: a) -> String where a: Showable { Showable.show(x) } fn apply(f, x) { f(x) } fn main() { println(apply(display, "text")) } diff --git a/tests/golden/repros/verify/tca_tca4_control.silt b/tests/golden/repros/verify/tca_tca4_control.silt index f50cce0da..87681aa42 100644 --- a/tests/golden/repros/verify/tca_tca4_control.silt +++ b/tests/golden/repros/verify/tca_tca4_control.silt @@ -1,5 +1,5 @@ -- verdict: same trait Showable { fn show(self) -> String } trait Showable for Int { fn show(self) -> String { "int" } } -fn display(x: a) -> String where a: Showable { x.show() } +fn display(x: a) -> String where a: Showable { Showable.show(x) } fn main() { println(display("text")) } diff --git a/tests/golden/repros/verify/ts2_t13.silt b/tests/golden/repros/verify/ts2_t13.silt index ce4f9a416..57a5f8a8a 100644 --- a/tests/golden/repros/verify/ts2_t13.silt +++ b/tests/golden/repros/verify/ts2_t13.silt @@ -6,6 +6,6 @@ trait Equal for P { fn main() { let a = P { x: 1 } let b = P { x: 2 } - println(a.equal(b)) + println(a == b) println(a == b) } diff --git a/tests/golden/repros/verify/ts_ts2_agent.silt b/tests/golden/repros/verify/ts_ts2_agent.silt index 7d25b645f..540ea1ea2 100644 --- a/tests/golden/repros/verify/ts_ts2_agent.silt +++ b/tests/golden/repros/verify/ts_ts2_agent.silt @@ -1,7 +1,7 @@ -- verdict: same trait Same { fn same(self) -> Self } trait Same for String { fn same(self) -> Self { self } } -fn coerce(x) { x.same() } +fn coerce(x) { Same.same(x) } fn main() { let f: Fn(Int) -> Int = coerce("callme") println(f(1)) diff --git a/tests/golden/typecheck/aliases/round74_parametric_alias_trait_impl__user_trait_dispatch.silt b/tests/golden/typecheck/aliases/round74_parametric_alias_trait_impl__user_trait_dispatch.silt index 719a80196..ea85bf6a7 100644 --- a/tests/golden/typecheck/aliases/round74_parametric_alias_trait_impl__user_trait_dispatch.silt +++ b/tests/golden/typecheck/aliases/round74_parametric_alias_trait_impl__user_trait_dispatch.silt @@ -3,5 +3,5 @@ trait Show { fn show(self) -> String } trait Show for Pair(a) { fn show(self) -> String { "p" } } fn main() { let p: Pair(Int) = (1, 2) - println(p.show()) + println(Show.show(p)) } diff --git a/tests/golden/typecheck/aliases/structural_method__through_an_alias_keeps_its_arguments.silt b/tests/golden/typecheck/aliases/structural_method__through_an_alias_keeps_its_arguments.silt deleted file mode 100644 index fd8da40fc..000000000 --- a/tests/golden/typecheck/aliases/structural_method__through_an_alias_keeps_its_arguments.silt +++ /dev/null @@ -1,13 +0,0 @@ --- cmd: check --- exit: 1 --- A method of a structural trait written through an alias is the method --- of the type the alias names, with the alias's arguments: `Ints` is a --- `List(Int)`, so a list of strings is no argument of `Ints.display`. -type Ints = List(Int) - -fn main() { - println(Ints.display(["s"])) - println(Ints.display([1, 2])) - let t = Ints - println(t.compare([1], ["t"])) -} diff --git a/tests/golden/typecheck/aliases/structural_method__through_an_alias_keeps_its_arguments.stderr b/tests/golden/typecheck/aliases/structural_method__through_an_alias_keeps_its_arguments.stderr deleted file mode 100644 index 9396756cd..000000000 --- a/tests/golden/typecheck/aliases/structural_method__through_an_alias_keeps_its_arguments.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[type]: type mismatch: expected Int, got String - --> structural_method__through_an_alias_keeps_its_arguments.silt:9:24 - | - 9 | println(Ints.display(["s"])) - | ^^^^^ type mismatch: expected Int, got String - -error[type]: type mismatch: expected Int, got String - --> structural_method__through_an_alias_keeps_its_arguments.silt:12:26 - | - 12 | println(t.compare([1], ["t"])) - | ^^^^^ type mismatch: expected Int, got String diff --git a/tests/golden/typecheck/aliases/type_alias__trait_impl_on_alias.silt b/tests/golden/typecheck/aliases/type_alias__trait_impl_on_alias.silt index 5d96f518d..8b5b1db7e 100644 --- a/tests/golden/typecheck/aliases/type_alias__trait_impl_on_alias.silt +++ b/tests/golden/typecheck/aliases/type_alias__trait_impl_on_alias.silt @@ -4,5 +4,5 @@ trait PhDByteShow { fn pretty(self) -> String } trait PhDByteShow for PhDBytShow { fn pretty(self) -> String { "bytes" } } fn main() { let xs: PhDBytShow = [1, 2, 3] - println(xs.pretty()) + println(PhDByteShow.pretty(xs)) } diff --git a/tests/golden/typecheck/assoc_types/associated_types__method_call_through_projection.silt b/tests/golden/typecheck/assoc_types/associated_types__method_call_through_projection.silt index 029e55abf..95254c88d 100644 --- a/tests/golden/typecheck/assoc_types/associated_types__method_call_through_projection.silt +++ b/tests/golden/typecheck/assoc_types/associated_types__method_call_through_projection.silt @@ -14,7 +14,7 @@ trait Producer for Wrap { } fn use_it(w: Wrap) -> Int { - w.produce() + Producer.produce(w) } fn main() {} diff --git a/tests/golden/typecheck/assoc_types/associated_types__projections_of_same_type_unify.silt b/tests/golden/typecheck/assoc_types/associated_types__projections_of_same_type_unify.silt index 94378aac8..fa27c43f7 100644 --- a/tests/golden/typecheck/assoc_types/associated_types__projections_of_same_type_unify.silt +++ b/tests/golden/typecheck/assoc_types/associated_types__projections_of_same_type_unify.silt @@ -14,7 +14,7 @@ trait Pair for IntPair { } fn use_it(x: IntPair, y: IntPair) -> Int { - x.first() + y.first() + Pair.first(x) + Pair.first(y) } fn main() {} diff --git a/tests/golden/typecheck/assoc_types/associated_types_runtime__distinct_bindings_per_impl.silt b/tests/golden/typecheck/assoc_types/associated_types_runtime__distinct_bindings_per_impl.silt index cb80e199c..242fa824b 100644 --- a/tests/golden/typecheck/assoc_types/associated_types_runtime__distinct_bindings_per_impl.silt +++ b/tests/golden/typecheck/assoc_types/associated_types_runtime__distinct_bindings_per_impl.silt @@ -18,7 +18,7 @@ trait Stream for B { fn main() { let a = A { x: 9 } - println(a.first()) + println(Stream.first(a)) let b = B { y: "bee" } - println(b.first()) + println(Stream.first(b)) } diff --git a/tests/golden/typecheck/assoc_types/associated_types_runtime__method_returns_bound_int.silt b/tests/golden/typecheck/assoc_types/associated_types_runtime__method_returns_bound_int.silt index 0a7d783ea..4823d5ef2 100644 --- a/tests/golden/typecheck/assoc_types/associated_types_runtime__method_returns_bound_int.silt +++ b/tests/golden/typecheck/assoc_types/associated_types_runtime__method_returns_bound_int.silt @@ -15,5 +15,5 @@ trait Stream for Wrap { fn main() { let w = Wrap { v: 7 } - println(w.first()) + println(Stream.first(w)) } diff --git a/tests/golden/typecheck/assoc_types/associated_types_runtime__multiple_assoc_types.silt b/tests/golden/typecheck/assoc_types/associated_types_runtime__multiple_assoc_types.silt index 6ee0db667..05842af4f 100644 --- a/tests/golden/typecheck/assoc_types/associated_types_runtime__multiple_assoc_types.silt +++ b/tests/golden/typecheck/assoc_types/associated_types_runtime__multiple_assoc_types.silt @@ -17,6 +17,6 @@ trait Pair for IntStringPair { fn main() { let p = IntStringPair { a: 13, b: "ok" } - println(p.first()) - println(p.second()) + println(Pair.first(p)) + println(Pair.second(p)) } diff --git a/tests/golden/typecheck/assoc_types/associated_types_runtime__supertrait_assoc_type.silt b/tests/golden/typecheck/assoc_types/associated_types_runtime__supertrait_assoc_type.silt index d57feac23..1dd8adb86 100644 --- a/tests/golden/typecheck/assoc_types/associated_types_runtime__supertrait_assoc_type.silt +++ b/tests/golden/typecheck/assoc_types/associated_types_runtime__supertrait_assoc_type.silt @@ -20,5 +20,5 @@ trait Sub for Wrap { fn main() { let w = Wrap { v: 41 } - println(w.first()) + println(Sub.first(w)) } diff --git a/tests/golden/typecheck/assoc_types/impl_type_variable__a_call_at_another_type_is_rejected.silt b/tests/golden/typecheck/assoc_types/impl_type_variable__a_call_at_another_type_is_rejected.silt index 95670f407..a91e25cad 100644 --- a/tests/golden/typecheck/assoc_types/impl_type_variable__a_call_at_another_type_is_rejected.silt +++ b/tests/golden/typecheck/assoc_types/impl_type_variable__a_call_at_another_type_is_rejected.silt @@ -27,7 +27,7 @@ trait Container for Box(a) where a: Equal { fn main() { let w = Box { item: 2 } - println(w.unwrap() + "x") - println(w.holds("two")) - let n: String = Box { item: 1 }.unwrap() + println(Container.unwrap(w) + "x") + println(Container.holds(w, "two")) + let n: String = Container.unwrap(Box { item: 1 }) } diff --git a/tests/golden/typecheck/assoc_types/impl_type_variable__in_a_method_of_an_impl_that_binds_it.silt b/tests/golden/typecheck/assoc_types/impl_type_variable__in_a_method_of_an_impl_that_binds_it.silt index 92a9ec176..a5ba991ce 100644 --- a/tests/golden/typecheck/assoc_types/impl_type_variable__in_a_method_of_an_impl_that_binds_it.silt +++ b/tests/golden/typecheck/assoc_types/impl_type_variable__in_a_method_of_an_impl_that_binds_it.silt @@ -22,7 +22,7 @@ trait Container { fn holds(self, x: Self::Item) -> Bool fn all(self) -> List(Self::Item) fn twice(self) -> (Self::Item, Self::Item) { - (self.unwrap(), self.unwrap()) + (Container.unwrap(self), Container.unwrap(self)) } } @@ -45,35 +45,35 @@ trait Container for Pair(a, b) where a: Equal, b: Equal { (self.right, self.left) } fn holds(self, x: (b, a)) -> Bool { - self.unwrap() == x + Container.unwrap(self) == x } fn all(self) -> List((b, a)) { - [self.unwrap()] + [Container.unwrap(self)] } } fn first(c: c) -> ::Item where c: Container { - c.unwrap() + Container.unwrap(c) } fn main() { let w = Box { item: 2 } - println(w.unwrap() + 1) - println(w.holds(2)) - println(list.map(w.all(), { n -> n * 10 })) - let (p, q) = w.twice() + println(Container.unwrap(w) + 1) + println(Container.holds(w, 2)) + println(list.map(Container.all(w), { n -> n * 10 })) + let (p, q) = Container.twice(w) println(p + q) println(first(w) + 5) let s = Box { item: "s" } - println("{s.unwrap()}!") - println(s.holds("t")) + println("{Container.unwrap(s)}!") + println(Container.holds(s, "t")) println(first(s)) let pr = Pair { left: 1, right: "r" } - let (r, l) = pr.unwrap() + let (r, l) = Container.unwrap(pr) println("{r} {l + 1}") - println(pr.holds(("r", 1))) - let ((r2, l2), _) = pr.twice() + println(Container.holds(pr, ("r", 1))) + let ((r2, l2), _) = Container.twice(pr) println("{r2} {l2 + 2}") - println(Box.unwrap(Box { item: 4 }) + 1) - println(Box { item: Box { item: 7 } }.unwrap().unwrap() + 1) + println(Container.unwrap(Box { item: 4 }) + 1) + println(Container.unwrap(Container.unwrap(Box { item: Box { item: 7 } })) + 1) } diff --git a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__different_assoc_names_rejected.silt b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__different_assoc_names_rejected.silt index 161d7af7c..5d4c8f689 100644 --- a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__different_assoc_names_rejected.silt +++ b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__different_assoc_names_rejected.silt @@ -9,7 +9,7 @@ trait Pair { } fn bad(s: a) -> ::First where a: Pair { - s.second() + Pair.second(s) } fn main() { diff --git a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__different_trait_names_rejected.silt b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__different_trait_names_rejected.silt index 622f7fac1..5671b4745 100644 --- a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__different_trait_names_rejected.silt +++ b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__different_trait_names_rejected.silt @@ -12,7 +12,7 @@ trait B { } fn bad(s: a) -> ::Item where a: A + B { - s.bi() + B.bi(s) } fn main() { diff --git a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__identical_projections_in_list.silt b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__identical_projections_in_list.silt index 628057429..12ddba935 100644 --- a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__identical_projections_in_list.silt +++ b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__identical_projections_in_list.silt @@ -11,7 +11,7 @@ trait Stream for Wrap { } fn pair(s: a) where a: Stream { - let xs = [s.first(), s.first()] + let xs = [Stream.first(s), Stream.first(s)] xs } diff --git a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_arithmetic.silt b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_arithmetic.silt index ba2c5d4e5..a78ce26c4 100644 --- a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_arithmetic.silt +++ b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_arithmetic.silt @@ -11,7 +11,7 @@ trait Stream for Wrap { } fn add_two(s: a) where a: Stream { - s.first() + s.first() + Stream.first(s) + Stream.first(s) } fn main() { diff --git a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_equality.silt b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_equality.silt index 40318f223..eb0db13b2 100644 --- a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_equality.silt +++ b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_equality.silt @@ -11,8 +11,8 @@ trait Stream for Wrap { } fn same(s: a) -> Bool where a: Stream { - let x = s.first() - let y = s.first() + let x = Stream.first(s) + let y = Stream.first(s) x == y } diff --git a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_list_direct.silt b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_list_direct.silt index 18c945780..1e77b9eae 100644 --- a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_list_direct.silt +++ b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_list_direct.silt @@ -11,7 +11,7 @@ trait Stream for Wrap { } fn pair(s: a) where a: Stream { - [s.first(), s.first()] + [Stream.first(s), Stream.first(s)] } fn main() { diff --git a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_return_position.silt b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_return_position.silt index dcdb0c0f1..441aafa9e 100644 --- a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_return_position.silt +++ b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projection_return_position.silt @@ -11,7 +11,7 @@ trait Stream for Wrap { } fn grab(s: a) -> ::Item where a: Stream { - s.first() + Stream.first(s) } fn main() { diff --git a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projections_distinct_tyvars.silt b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projections_distinct_tyvars.silt index 716485831..afd18f6d8 100644 --- a/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projections_distinct_tyvars.silt +++ b/tests/golden/typecheck/assoc_types/round92_assoc_proj_unify__projections_distinct_tyvars.silt @@ -16,7 +16,7 @@ trait Stream for Wrap { } fn pick(x: a, y: b) where a: Stream, b: Stream { - let xs = [x.first(), y.first()] + let xs = [Stream.first(x), Stream.first(y)] xs } diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__compare_box_int.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__compare_box_int.silt index faa4d1e25..3a512e99a 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__compare_box_int.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__compare_box_int.silt @@ -1,5 +1,5 @@ type Box(a) { Foo(a), Bar(a, a), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Foo(1), Foo(2))) println(cmp_gen(Foo(2), Foo(1))) diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__compare_box_string.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__compare_box_string.silt index ec0037370..5555ba111 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__compare_box_string.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__compare_box_string.silt @@ -1,5 +1,5 @@ type Box(a) { Foo(a), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Foo("apple"), Foo("banana"))) println(cmp_gen(Foo("banana"), Foo("apple"))) diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__direct_method_call.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__direct_method_call.silt index 96bd23ad2..e58b393b2 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__direct_method_call.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__direct_method_call.silt @@ -3,6 +3,6 @@ fn main() { let w = Wrapped { value: 7 } let v = Wrapped { value: 7 } let u = Wrapped { value: 8 } - println(w.equal(v)) - println(w.equal(u)) + println(w == v) + println(w == u) } diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__display_generic_record.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__display_generic_record.silt index 76e79ade8..65bdffccc 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__display_generic_record.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__display_generic_record.silt @@ -1,5 +1,5 @@ type Wrapped(a) { value: a } -fn d(a: a) -> String where a: Display { a.display() } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { let w = Wrapped { value: 42 } println(d(w)) diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__equal_generic_record.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__equal_generic_record.silt index 56f1c071c..a52b0fa11 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__equal_generic_record.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__equal_generic_record.silt @@ -1,5 +1,5 @@ type Wrapped(a) { value: a } -fn eq_gen(a: a, b: a) -> Bool where a: Equal { a.equal(b) } +fn eq_gen(a: a, b: a) -> Bool where a: Equal { a == b } fn main() { let p = Wrapped { value: 1 } let q = Wrapped { value: 1 } diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__hash_generic_enum.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__hash_generic_enum.silt index 60e5b9d69..00c6fbe57 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__hash_generic_enum.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__hash_generic_enum.silt @@ -1,7 +1,7 @@ -- Equal generic-enum values hash equal; different payloads and the -- Just-vs-Nothing arms hash differently. type Maybe(a) { Just(a), Nothing, } -fn h(a: a) -> Int where a: Hash { a.hash() } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } fn main() { let n: Maybe(Int) = Nothing println(h(Just(7)) == h(Just(7))) diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__holder_display.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__holder_display.silt index 06eba36c4..b08c7da77 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__holder_display.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__holder_display.silt @@ -1,5 +1,5 @@ type Holder(a) { value: a } -fn d(a: a) -> String where a: Display { a.display() } +fn d(a: a) -> String where a: Display { "{a}" } fn main() { let h = Holder { value: 5 } println(d(h)) diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__multi_param_compare.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__multi_param_compare.silt index 89c12b6f2..4e295ae34 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__multi_param_compare.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__multi_param_compare.silt @@ -1,5 +1,5 @@ type Pair(a, b) { Tup(a, b), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Tup(1, "z"), Tup(2, "a"))) -- first differs: 1 < 2 println(cmp_gen(Tup(1, "a"), Tup(1, "b"))) -- tie on first, second differs diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__phantom_compare.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__phantom_compare.silt index 7fa7800d4..e3a8c0650 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__phantom_compare.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__phantom_compare.silt @@ -1,5 +1,5 @@ type Phantom(a) { Tag, } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { let x: Phantom(Int) = Tag let y: Phantom(Int) = Tag diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__qualified_call.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__qualified_call.silt index 4284d07d2..633e99c61 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__qualified_call.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__qualified_call.silt @@ -1,7 +1,7 @@ -- Qualified `Box.compare` matches the trait-bound call form. type Box(a) { Foo(a), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Foo(1), Foo(2))) - println(Box.compare(Foo(1), Foo(2))) + println(Compare.compare(Foo(1), Foo(2))) } diff --git a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__self_recursive_tree.silt b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__self_recursive_tree.silt index f054492a6..190c2e560 100644 --- a/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__self_recursive_tree.silt +++ b/tests/golden/typecheck/auto_derive/auto_derive_generic_synth__self_recursive_tree.silt @@ -1,5 +1,5 @@ type Tree(a) { Leaf, Node(Tree(a), Tree(a)), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { let l: Tree(Int) = Leaf let n: Tree(Int) = Node(Leaf, Leaf) diff --git a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__builtin_weekday.silt b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__builtin_weekday.silt index 6399dbcf3..d948d83c5 100644 --- a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__builtin_weekday.silt +++ b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__builtin_weekday.silt @@ -1,5 +1,5 @@ import time -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(time.Monday, time.Friday)) println(cmp_gen(time.Sunday, time.Monday)) diff --git a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__builtin_weekday_chain.silt b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__builtin_weekday_chain.silt index c0cf3883b..d969171b7 100644 --- a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__builtin_weekday_chain.silt +++ b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__builtin_weekday_chain.silt @@ -1,5 +1,5 @@ import time -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(time.Monday, time.Tuesday)) println(cmp_gen(time.Tuesday, time.Wednesday)) diff --git a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__color_basic.silt b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__color_basic.silt index 3d8e94e20..7f7d5c821 100644 --- a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__color_basic.silt +++ b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__color_basic.silt @@ -1,5 +1,5 @@ type Color { Red, Green, Blue, } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Red, Green)) println(cmp_gen(Green, Red)) diff --git a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__constructor_args.silt b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__constructor_args.silt index d299d6fcd..fe68410fc 100644 --- a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__constructor_args.silt +++ b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__constructor_args.silt @@ -1,5 +1,5 @@ type Tagged { Foo(Int), Bar(Int), } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Foo(1), Bar(1))) println(cmp_gen(Foo(1), Foo(2))) diff --git a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__reverse_alphabetical.silt b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__reverse_alphabetical.silt index 73a2ca9b0..2092eb017 100644 --- a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__reverse_alphabetical.silt +++ b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__reverse_alphabetical.silt @@ -1,6 +1,6 @@ -- Declaration order, not alphabetical: Z < A. type Backwards { Z, Y, A, } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(Z, A)) } diff --git a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__three_variants.silt b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__three_variants.silt index cdc951645..ea992eb94 100644 --- a/tests/golden/typecheck/auto_derive/variant_decl_order_compare__three_variants.silt +++ b/tests/golden/typecheck/auto_derive/variant_decl_order_compare__three_variants.silt @@ -1,5 +1,5 @@ type Three { First, Second, Third, } -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen(First, Second)) println(cmp_gen(Second, Third)) diff --git a/tests/golden/typecheck/builtin_types/http_bodies__a_response_body_read_as_text.silt b/tests/golden/typecheck/builtin_types/http_bodies__a_response_body_read_as_text.silt index e54f39953..ceb4e5f20 100644 --- a/tests/golden/typecheck/builtin_types/http_bodies__a_response_body_read_as_text.silt +++ b/tests/golden/typecheck/builtin_types/http_bodies__a_response_body_read_as_text.silt @@ -9,6 +9,6 @@ import string fn main() { match http.get("http://127.0.0.1:1/") { Ok(resp) -> println(string.length(resp.body)) - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) } } diff --git a/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.silt b/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.silt index 20466f082..8f90866de 100644 --- a/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.silt +++ b/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.silt @@ -1,52 +1,20 @@ -- cmd: check -- exit: 1 --- A method that the bounds of a type variable each give is ambiguous --- called on a value of the variable, on the variable as a `type` --- parameter, and on a value whose type becomes the variable later; the --- variable is bounded already, so the help names the bounds and says to --- call the method from a function bounded by only one of them. The --- bounds as the `where` clause writes them, with their arguments. +-- A method that makes a value, which the bounds of a type variable +-- each give, is ambiguous called on the variable as a `type` +-- parameter; the variable is bounded already, so the help names the +-- bounds and says to call the method from a function bounded by only +-- one of them. trait A { fn make() -> Self - fn show(self) -> String } trait B { fn make() -> Self - fn show(self) -> String -} - -trait C { - fn show(self) -> String -} - -trait Conv(t) { - fn show(self) -> String } fn on_type(type a) -> a where a: A, a: B { a.make() } -fn on_value(x: a) -> String where a: A + B { - x.show() -} - -fn first(x: a) -> a { - x -} - -fn later(x: a) -> String where a: A + B { - let f = { y -> first(y).show() } - f(x) -} - -fn three(x: a) -> String where a: C + B + A { - x.show() -} - -fn with_arguments(x: a) -> String where a: Conv(Int), a: A { - x.show() -} - fn main() {} diff --git a/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.stderr b/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.stderr index d5d5b7719..0adcdd288 100644 --- a/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.stderr +++ b/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.stderr @@ -1,34 +1,6 @@ error[type]: ambiguous method 'make' on `type a`: provided by traits A, B - --> ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.silt:28:3 + --> ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.silt:17:3 | - 28 | a.make() + 17 | a.make() | ^^^^^^ ambiguous method 'make' on `type a`: provided by traits A, B = help: the bounds `A` and `B` both give `make`: call it from a function bounded by only one of them - -error[type]: ambiguous method 'show' on a value of type `a`: provided by traits A, B - --> ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.silt:32:3 - | - 32 | x.show() - | ^^^^^^ ambiguous method 'show' on a value of type `a`: provided by traits A, B - = help: the bounds `A` and `B` both give `show`: call it from a function bounded by only one of them - -error[type]: ambiguous method 'show' on a value of type `a`: provided by traits A, B - --> ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.silt:40:18 - | - 40 | let f = { y -> first(y).show() } - | ^^^^^^^^^^^^^ ambiguous method 'show' on a value of type `a`: provided by traits A, B - = help: the bounds `A` and `B` both give `show`: call it from a function bounded by only one of them - -error[type]: ambiguous method 'show' on a value of type `a`: provided by traits A, B, C - --> ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.silt:45:3 - | - 45 | x.show() - | ^^^^^^ ambiguous method 'show' on a value of type `a`: provided by traits A, B, C - = help: the bounds `A`, `B` and `C` all give `show`: call it from a function bounded by only one of them - -error[type]: ambiguous method 'show' on a value of type `a`: provided by traits A, Conv - --> ambiguous_method__on_a_bounded_type_variable_the_help_names_the_bounds.silt:49:3 - | - 49 | x.show() - | ^^^^^^ ambiguous method 'show' on a value of type `a`: provided by traits A, Conv - = help: the bounds `A` and `Conv(Int)` both give `show`: call it from a function bounded by only one of them diff --git a/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_type_the_help_names_the_program_s_trait.stderr b/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_type_the_help_names_the_program_s_trait.stderr deleted file mode 100644 index d1b6ac86f..000000000 --- a/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_type_the_help_names_the_program_s_trait.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[type]: ambiguous method 'display' on type 'T': provided by traits Display, Pretty - --> ambiguous_method__on_a_type_the_help_names_the_program_s_trait.silt:21:11 - | - 21 | println(T.display(T { n: 1 })) - | ^^^^^^^^^ ambiguous method 'display' on type 'T': provided by traits Display, Pretty - = help: say which is meant: call it through a function bounded by the trait you mean, `where a: Pretty` - -error[type]: ambiguous method 'display' on type 'Int': provided by traits Display, Pretty - --> ambiguous_method__on_a_type_the_help_names_the_program_s_trait.silt:22:11 - | - 22 | println(Int.display(5)) - | ^^^^^^^^^^^ ambiguous method 'display' on type 'Int': provided by traits Display, Pretty - = help: say which is meant: call it through a function bounded by the trait you mean, `where a: Pretty` diff --git a/tests/golden/typecheck/diagnostics/ambiguous_method__one_wording.silt b/tests/golden/typecheck/diagnostics/ambiguous_method__one_wording.silt deleted file mode 100644 index b3fc81a47..000000000 --- a/tests/golden/typecheck/diagnostics/ambiguous_method__one_wording.silt +++ /dev/null @@ -1,73 +0,0 @@ --- cmd: check --- exit: 1 --- A method two traits provide is ambiguous in one wording, the traits --- in the order of their names, wherever the call is decided: on a type, --- on a bounded value, on a value whose type is not known, on a value --- whose type becomes a bounded variable later, on a `type` parameter. --- A method none of the bounds provide is, there too, what it is where --- the receiver is known at once. -trait Zeta { - fn show(self) -> String -} - -trait Alpha { - fn show(self) -> String -} - -trait Other { - fn other(self) -> String -} - -trait Zeta for Int { - fn show(self) -> String { - "z" - } -} - -trait Alpha for Int { - fn show(self) -> String { - "a" - } -} - -fn concrete() -> String { - 7.show() -} - -fn bounded(x: b) -> String where b: Zeta + Alpha { - x.show() -} - -fn unknown(x) { - x.show() -} - -fn first(x: a) -> a { - x -} - -fn later(x: b) -> String where b: Zeta + Alpha { - let f = { y -> first(y).show() } - f(x) -} - -fn missing(x: b) -> String where b: Other { - let f = { y -> first(y).show() } - f(x) -} - -fn on_type(type b) -> String where b: Zeta + Alpha { - b.show(b) -} - -fn on_name() -> String { - Int.show(7) -} - -fn main() { - println(concrete()) - println(bounded(7)) - println(unknown(7)) - println(later(7)) - println(on_name()) -} diff --git a/tests/golden/typecheck/diagnostics/ambiguous_method__one_wording.stderr b/tests/golden/typecheck/diagnostics/ambiguous_method__one_wording.stderr deleted file mode 100644 index b5545e49b..000000000 --- a/tests/golden/typecheck/diagnostics/ambiguous_method__one_wording.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[type]: ambiguous method 'show' on type 'Int': provided by traits Alpha, Zeta - --> ambiguous_method__one_wording.silt:34:3 - | - 34 | 7.show() - | ^^^^^^ ambiguous method 'show' on type 'Int': provided by traits Alpha, Zeta - = help: say which is meant: annotate the receiver's type, or bound it with a `where` clause - -error[type]: ambiguous method 'show' on a value of type `b`: provided by traits Alpha, Zeta - --> ambiguous_method__one_wording.silt:38:3 - | - 38 | x.show() - | ^^^^^^ ambiguous method 'show' on a value of type `b`: provided by traits Alpha, Zeta - = help: the bounds `Alpha` and `Zeta` both give `show`: call it from a function bounded by only one of them - -error[type]: ambiguous method 'show' on a value whose type is not known: provided by traits Alpha, Zeta - --> ambiguous_method__one_wording.silt:42:3 - | - 42 | x.show() - | ^^^^^^ ambiguous method 'show' on a value whose type is not known: provided by traits Alpha, Zeta - = help: say which is meant: annotate the receiver's type, or bound it with a `where` clause - -error[type]: ambiguous method 'show' on a value of type `b`: provided by traits Alpha, Zeta - --> ambiguous_method__one_wording.silt:50:18 - | - 50 | let f = { y -> first(y).show() } - | ^^^^^^^^^^^^^ ambiguous method 'show' on a value of type `b`: provided by traits Alpha, Zeta - = help: the bounds `Alpha` and `Zeta` both give `show`: call it from a function bounded by only one of them - -error[type]: no method 'show' found in trait constraints (Other) - --> ambiguous_method__one_wording.silt:55:18 - | - 55 | let f = { y -> first(y).show() } - | ^^^^^^^^^^^^^ no method 'show' found in trait constraints (Other) - -error[type]: ambiguous method 'show' on `type b`: provided by traits Alpha, Zeta - --> ambiguous_method__one_wording.silt:60:3 - | - 60 | b.show(b) - | ^^^^^^ ambiguous method 'show' on `type b`: provided by traits Alpha, Zeta - = help: the bounds `Alpha` and `Zeta` both give `show`: call it from a function bounded by only one of them - -error[type]: ambiguous method 'show' on type 'Int': provided by traits Alpha, Zeta - --> ambiguous_method__one_wording.silt:64:3 - | - 64 | Int.show(7) - | ^^^^^^^^ ambiguous method 'show' on type 'Int': provided by traits Alpha, Zeta - = help: say which is meant: call it through a function bounded by the trait you mean, `where a: Alpha` diff --git a/tests/golden/typecheck/diagnostics/ambiguous_method__the_help_names_the_bounds_as_written/case.stderr b/tests/golden/typecheck/diagnostics/ambiguous_method__the_help_names_the_bounds_as_written/case.stderr deleted file mode 100644 index 48e95ea8f..000000000 --- a/tests/golden/typecheck/diagnostics/ambiguous_method__the_help_names_the_bounds_as_written/case.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[type]: ambiguous method 'show' on a value of type `a`: provided by traits Br, shapes.Ar - --> main.silt:32:3 - | - 32 | x.show() - | ^^^^^^ ambiguous method 'show' on a value of type `a`: provided by traits Br, shapes.Ar - = help: the bounds `Br` and `shapes.Ar` both give `show`: call it from a function bounded by only one of them - -error[type]: ambiguous method 'display' on a value of type `a`: provided by traits Display, Shows - --> main.silt:36:3 - | - 36 | x.display() - | ^^^^^^^^^ ambiguous method 'display' on a value of type `a`: provided by traits Display, Shows - = help: the bounds `Display` and `Shows` both give `display`: call it from a function bounded by only one of them - -error[type]: ambiguous method 'show' on a value of type `a`: provided by traits Ar, Br - --> main.silt:40:3 - | - 40 | x.show() - | ^^^^^^ ambiguous method 'show' on a value of type `a`: provided by traits Ar, Br - = help: the bounds `Br` and `S` both give `show`: call it from a function bounded by only one of them - -error[type]: ambiguous method 'show' on a value of type `a`: provided by traits Ar, Br - --> main.silt:44:3 - | - 44 | x.show() - | ^^^^^^ ambiguous method 'show' on a value of type `a`: provided by traits Ar, Br - = help: the bounds `Ar` and `Br` both give `show`: call it from a function bounded by only one of them diff --git a/tests/golden/typecheck/diagnostics/ambiguous_method__the_help_names_the_bounds_as_written/main.silt b/tests/golden/typecheck/diagnostics/ambiguous_method__the_help_names_the_bounds_as_written/main.silt deleted file mode 100644 index 2cd81d648..000000000 --- a/tests/golden/typecheck/diagnostics/ambiguous_method__the_help_names_the_bounds_as_written/main.silt +++ /dev/null @@ -1,47 +0,0 @@ --- cmd: check --- exit: 1 --- The help of a method two bounds of a type variable give names the --- bounds as the program writes them: a trait of another module with its --- module (`shapes.Ar`), a prelude trait by its name (`Display`), and a --- bound whose supertrait gives the method (`S`), not the supertrait. --- Where one bound gives the method by two of its supertraits, those --- are named. -import shapes - -trait Ar { - fn show(self) -> String -} - -trait Br { - fn show(self) -> String -} - -trait S: Ar { - fn other(self) -> Int -} - -trait Both: Ar + Br { - fn other(self) -> Int -} - -trait Shows { - fn display(self) -> String -} - -fn of_another_module(x: a) -> String where a: shapes.Ar, a: Br { - x.show() -} - -fn of_the_prelude(x: a) -> String where a: Display, a: Shows { - x.display() -} - -fn by_a_supertrait(x: a) -> String where a: S, a: Br { - x.show() -} - -fn by_one_bound(x: a) -> String where a: Both { - x.show() -} - -fn main() {} diff --git a/tests/golden/typecheck/diagnostics/ambiguous_method__the_help_names_the_bounds_as_written/shapes.silt b/tests/golden/typecheck/diagnostics/ambiguous_method__the_help_names_the_bounds_as_written/shapes.silt deleted file mode 100644 index 39282a6dc..000000000 --- a/tests/golden/typecheck/diagnostics/ambiguous_method__the_help_names_the_bounds_as_written/shapes.silt +++ /dev/null @@ -1,3 +0,0 @@ -pub trait Ar { - fn show(self) -> String -} diff --git a/tests/golden/typecheck/diagnostics/hidden_module__a_local_hides_an_imported_module.silt b/tests/golden/typecheck/diagnostics/hidden_module__a_local_hides_an_imported_module.silt index a18d3b8ff..759e56644 100644 --- a/tests/golden/typecheck/diagnostics/hidden_module__a_local_hides_an_imported_module.silt +++ b/tests/golden/typecheck/diagnostics/hidden_module__a_local_hides_an_imported_module.silt @@ -1,9 +1,8 @@ -- exit: 1 -- A local named like an imported module hides it: `list.length(..)` --- then asks the local for a method. When the local has no such field --- or method and the module has a member of that name, the help says --- which local hides the module (a `let`, a parameter, a closure's --- parameter). +-- then reads a field of the local. When the local has no such field +-- and the module has a member of that name, the help says which local +-- hides the module (a `let`, a parameter, a closure's parameter). import list import map import string diff --git a/tests/golden/typecheck/diagnostics/hidden_module__a_local_hides_an_imported_module.stderr b/tests/golden/typecheck/diagnostics/hidden_module__a_local_hides_an_imported_module.stderr index ef91a910b..6e5b9f3de 100644 --- a/tests/golden/typecheck/diagnostics/hidden_module__a_local_hides_an_imported_module.stderr +++ b/tests/golden/typecheck/diagnostics/hidden_module__a_local_hides_an_imported_module.stderr @@ -1,27 +1,27 @@ -error[type]: unknown method 'to_upper' on type String - --> hidden_module__a_local_hides_an_imported_module.silt:12:3 +error[type]: type 'String' has no field 'to_upper' + --> hidden_module__a_local_hides_an_imported_module.silt:11:3 | - 12 | string.to_upper(string) - | ^^^^^^^^^^^^^^^ unknown method 'to_upper' on type String - = help: `string` here is the local from line 11, which hides the module `string`; rename the local + 11 | string.to_upper(string) + | ^^^^^^^^^^^^^^^ type 'String' has no field 'to_upper' + = help: `string` here is the local from line 10, which hides the module `string`; rename the local -error[type]: unknown method 'length' on List - --> hidden_module__a_local_hides_an_imported_module.silt:17:11 +error[type]: type 'List(Int)' has no field 'length' + --> hidden_module__a_local_hides_an_imported_module.silt:16:11 | - 17 | println(list.length(list)) - | ^^^^^^^^^^^ unknown method 'length' on List - = help: `list` here is the local from line 16, which hides the module `list`; rename the local + 16 | println(list.length(list)) + | ^^^^^^^^^^^ type 'List(Int)' has no field 'length' + = help: `list` here is the local from line 15, which hides the module `list`; rename the local -error[type]: anon record has no field 'keys' - --> hidden_module__a_local_hides_an_imported_module.silt:19:11 +error[type]: type '{size: Int}' has no field 'keys' + --> hidden_module__a_local_hides_an_imported_module.silt:18:11 | - 19 | println(map.keys(map)) - | ^^^^^^^^ anon record has no field 'keys' - = help: `map` here is the local from line 18, which hides the module `map`; rename the local + 18 | println(map.keys(map)) + | ^^^^^^^^ type '{size: Int}' has no field 'keys' + = help: `map` here is the local from line 17, which hides the module `map`; rename the local -error[type]: unknown method 'reverse' on List - --> hidden_module__a_local_hides_an_imported_module.silt:20:32 +error[type]: type 'List(Int)' has no field 'reverse' + --> hidden_module__a_local_hides_an_imported_module.silt:19:32 | - 20 | let f = { list: List(Int) -> list.reverse(list) } - | ^^^^^^^^^^^^ unknown method 'reverse' on List - = help: `list` here is the local from line 20, which hides the module `list`; rename the local + 19 | let f = { list: List(Int) -> list.reverse(list) } + | ^^^^^^^^^^^^ type 'List(Int)' has no field 'reverse' + = help: `list` here is the local from line 19, which hides the module `list`; rename the local diff --git a/tests/golden/typecheck/diagnostics/hidden_module__an_alias_names_the_module_too.silt b/tests/golden/typecheck/diagnostics/hidden_module__an_alias_names_the_module_too.silt index 9d6e07a3e..7c6bdb979 100644 --- a/tests/golden/typecheck/diagnostics/hidden_module__an_alias_names_the_module_too.silt +++ b/tests/golden/typecheck/diagnostics/hidden_module__an_alias_names_the_module_too.silt @@ -1,7 +1,8 @@ -- exit: 1 -- A local named like a module's alias hides the module imported as -- that name: the help names the module and the alias. A local named --- like the module itself hides nothing here: no help for it. +-- like the module itself hides nothing here: its help is the one for a +-- function of the module, not the hidden-module one. import list as l fn main() { diff --git a/tests/golden/typecheck/diagnostics/hidden_module__an_alias_names_the_module_too.stderr b/tests/golden/typecheck/diagnostics/hidden_module__an_alias_names_the_module_too.stderr index f51833806..7ddffeb39 100644 --- a/tests/golden/typecheck/diagnostics/hidden_module__an_alias_names_the_module_too.stderr +++ b/tests/golden/typecheck/diagnostics/hidden_module__an_alias_names_the_module_too.stderr @@ -1,12 +1,13 @@ -error[type]: unknown method 'length' on List - --> hidden_module__an_alias_names_the_module_too.silt:9:11 - | - 9 | println(list.length(list)) - | ^^^^^^^^^^^ unknown method 'length' on List +error[type]: type 'List(Int)' has no field 'length' + --> hidden_module__an_alias_names_the_module_too.silt:10:11 + | + 10 | println(list.length(list)) + | ^^^^^^^^^^^ type 'List(Int)' has no field 'length' + = help: `length` is a function of module `list`: call it as `list.length(list)` -error[type]: unknown method 'length' on List - --> hidden_module__an_alias_names_the_module_too.silt:11:11 +error[type]: type 'List(Int)' has no field 'length' + --> hidden_module__an_alias_names_the_module_too.silt:12:11 | - 11 | println(l.length(l)) - | ^^^^^^^^ unknown method 'length' on List - = help: `l` here is the local from line 10, which hides the module `list` (imported as `l`); rename the local + 12 | println(l.length(l)) + | ^^^^^^^^ type 'List(Int)' has no field 'length' + = help: `l` here is the local from line 11, which hides the module `list` (imported as `l`); rename the local diff --git a/tests/golden/typecheck/diagnostics/hidden_module__no_help_without_the_module_or_its_member.silt b/tests/golden/typecheck/diagnostics/hidden_module__no_help_without_the_module_or_its_member.silt index 345a0df83..9faaa6fc2 100644 --- a/tests/golden/typecheck/diagnostics/hidden_module__no_help_without_the_module_or_its_member.silt +++ b/tests/golden/typecheck/diagnostics/hidden_module__no_help_without_the_module_or_its_member.silt @@ -1,6 +1,6 @@ -- exit: 1 --- stderr-contains: unknown method 'length' on List --- stderr-contains: unknown method 'frobnicate' on List +-- stderr-contains: type 'List(Int)' has no field 'length' +-- stderr-contains: type 'List(Int)' has no field 'frobnicate' -- stderr-not-contains: hides the module -- No help about a hidden module when the module is not imported, or -- when it has no member of the name; a local with the field is used. diff --git a/tests/golden/typecheck/diagnostics/method_arity__counts_the_arguments_written.silt b/tests/golden/typecheck/diagnostics/method_arity__counts_the_arguments_written.silt index 6b15106a6..f5de16ff3 100644 --- a/tests/golden/typecheck/diagnostics/method_arity__counts_the_arguments_written.silt +++ b/tests/golden/typecheck/diagnostics/method_arity__counts_the_arguments_written.silt @@ -1,14 +1,15 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: method `add` expects 1 argument, got 2 --- stderr-contains: error[type]: method `add` expects 1 argument, got 0 --- stderr-not-contains: expects 2 arguments --- A method's receiver is not one of the arguments its call writes; a --- piped value is. +-- stderr-contains: error[type]: `Adder.add` expects 2 arguments, got 3 +-- stderr-contains: error[type]: `Adder.add` expects 2 arguments, got 1 +-- stderr-contains: :12:11 +-- stderr-contains: :13:11 +-- A call through a trait counts every argument it writes, the one of +-- type Self and a piped value among them. trait Adder { fn add(self, x: Int) -> Int } trait Adder for Int { fn add(self, x: Int) -> Int { self + x } } fn main() { - println(5 |> 3.add(1)) - println(3.add(1, 2)) - println(3.add()) + println(5 |> Adder.add(3, 1)) + println(Adder.add(3)) + println(5 |> Adder.add(3)) } diff --git a/tests/golden/typecheck/diagnostics/rigid_variable_mismatch__names_the_variable.silt b/tests/golden/typecheck/diagnostics/rigid_variable_mismatch__names_the_variable.silt index 8f090ea69..c1205b40a 100644 --- a/tests/golden/typecheck/diagnostics/rigid_variable_mismatch__names_the_variable.silt +++ b/tests/golden/typecheck/diagnostics/rigid_variable_mismatch__names_the_variable.silt @@ -21,7 +21,7 @@ trait Shape { } fn area_of(s: t) -> t where t: Shape { - s.area() + Shape.area(s) } fn wrap(x: e) -> List(e) { diff --git a/tests/golden/typecheck/diagnostics/rigid_variable_mismatch__names_the_variable.stderr b/tests/golden/typecheck/diagnostics/rigid_variable_mismatch__names_the_variable.stderr index ffa3b7207..d701e2862 100644 --- a/tests/golden/typecheck/diagnostics/rigid_variable_mismatch__names_the_variable.stderr +++ b/tests/golden/typecheck/diagnostics/rigid_variable_mismatch__names_the_variable.stderr @@ -38,8 +38,8 @@ error[type]: type mismatch: expected a, got Int error[type]: type mismatch: expected t, got Int --> rigid_variable_mismatch__names_the_variable.silt:24:3 | - 24 | s.area() - | ^^^^^^^^ type mismatch: expected t, got Int + 24 | Shape.area(s) + | ^^^^^^^^^^^^^ type mismatch: expected t, got Int ::: rigid_variable_mismatch__names_the_variable.silt:23:15 | 23 | fn area_of(s: t) -> t where t: Shape { diff --git a/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_type_the_help_names_the_program_s_trait.silt b/tests/golden/typecheck/diagnostics/through_the_type__the_help_names_the_program_s_trait.silt similarity index 65% rename from tests/golden/typecheck/diagnostics/ambiguous_method__on_a_type_the_help_names_the_program_s_trait.silt rename to tests/golden/typecheck/diagnostics/through_the_type__the_help_names_the_program_s_trait.silt index 641d8cd5e..76ae7cbd5 100644 --- a/tests/golden/typecheck/diagnostics/ambiguous_method__on_a_type_the_help_names_the_program_s_trait.silt +++ b/tests/golden/typecheck/diagnostics/through_the_type__the_help_names_the_program_s_trait.silt @@ -1,8 +1,9 @@ -- cmd: check -- exit: 1 -- A method a program's trait and a builtin trait both give a type, --- called through the type, is ambiguous; the help names the program's --- trait, not the builtin one (`Pretty`, not `Display`). +-- taking a value of it, is called through its trait, not the type; the +-- help names the program's trait, not the builtin one (`Pretty`, not +-- `Display`, whose method is not called). trait Pretty { fn display(self) -> String } diff --git a/tests/golden/typecheck/diagnostics/through_the_type__the_help_names_the_program_s_trait.stderr b/tests/golden/typecheck/diagnostics/through_the_type__the_help_names_the_program_s_trait.stderr new file mode 100644 index 000000000..7d872d202 --- /dev/null +++ b/tests/golden/typecheck/diagnostics/through_the_type__the_help_names_the_program_s_trait.stderr @@ -0,0 +1,13 @@ +error[type]: type 'T' has no method 'display' + --> through_the_type__the_help_names_the_program_s_trait.silt:22:11 + | + 22 | println(T.display(T { n: 1 })) + | ^^^^^^^^^ type 'T' has no method 'display' + = help: `display` is a method of trait `Pretty`: call it as `Pretty.display(x)` + +error[type]: type 'Int' has no method 'display' + --> through_the_type__the_help_names_the_program_s_trait.silt:23:11 + | + 23 | println(Int.display(5)) + | ^^^^^^^^^^^ type 'Int' has no method 'display' + = help: `display` is a method of trait `Pretty`: call it as `Pretty.display(x)` diff --git a/tests/golden/typecheck/diagnostics/typechecker_soundness_round35__duplicate_impl_method.silt b/tests/golden/typecheck/diagnostics/typechecker_soundness_round35__duplicate_impl_method.silt index bc4eb9068..118aba078 100644 --- a/tests/golden/typecheck/diagnostics/typechecker_soundness_round35__duplicate_impl_method.silt +++ b/tests/golden/typecheck/diagnostics/typechecker_soundness_round35__duplicate_impl_method.silt @@ -10,5 +10,5 @@ trait Greet for Int { fn say(self) -> String { "two" } } fn main() { - println((1).say()) + println(Greet.say(1)) } diff --git a/tests/golden/typecheck/diagnostics/typechecker_soundness_round35__extraneous_impl_method.silt b/tests/golden/typecheck/diagnostics/typechecker_soundness_round35__extraneous_impl_method.silt index ac1174e0a..2d96305b0 100644 --- a/tests/golden/typecheck/diagnostics/typechecker_soundness_round35__extraneous_impl_method.silt +++ b/tests/golden/typecheck/diagnostics/typechecker_soundness_round35__extraneous_impl_method.silt @@ -10,5 +10,5 @@ trait Greeter for Int { fn secret(self) -> Int { 42 } } fn main() { - println((1).greet()) + println(Greeter.greet(1)) } diff --git a/tests/golden/typecheck/display/display_impl__a_body_that_does_not_check_is_the_one_error.silt b/tests/golden/typecheck/display/display_impl__a_body_that_does_not_check_is_the_one_error.silt index e0d6fa298..ccd9b834b 100644 --- a/tests/golden/typecheck/display/display_impl__a_body_that_does_not_check_is_the_one_error.silt +++ b/tests/golden/typecheck/display/display_impl__a_body_that_does_not_check_is_the_one_error.silt @@ -16,15 +16,15 @@ trait Display for D { } fn show(x: a) -> String where a: Display { - x.display() + "{x}" } fn main() { println(D { n: 1 }) println([D { n: 1 }]) println("{D { n: 1 }}") - println(D { n: 1 }.display()) + println(string.from(D { n: 1 })) println(show(D { n: 2 })) - println(D.display(D { n: 3 })) + println(string.from(D { n: 3 })) println(string.from(D { n: 4 })) } diff --git a/tests/golden/typecheck/display/display_impl__a_written_impl_shows_a_type_with_a_function_field.silt b/tests/golden/typecheck/display/display_impl__a_written_impl_shows_a_type_with_a_function_field.silt index 3ddfd8696..7140ae71a 100644 --- a/tests/golden/typecheck/display/display_impl__a_written_impl_shows_a_type_with_a_function_field.silt +++ b/tests/golden/typecheck/display/display_impl__a_written_impl_shows_a_type_with_a_function_field.silt @@ -17,7 +17,7 @@ trait Display for F { } fn main() { - println(MyErr { code: 1 }.message()) + println(Error.message(MyErr { code: 1 })) println(F { f: { x -> x + 1 } }) println([F { f: { x -> x + 2 } }]) } diff --git a/tests/golden/typecheck/display/display_impl__a_wrong_signature_is_the_one_error.silt b/tests/golden/typecheck/display/display_impl__a_wrong_signature_is_the_one_error.silt index 48260a067..d4d7b3a53 100644 --- a/tests/golden/typecheck/display/display_impl__a_wrong_signature_is_the_one_error.silt +++ b/tests/golden/typecheck/display/display_impl__a_wrong_signature_is_the_one_error.silt @@ -16,15 +16,15 @@ trait Display for D { } fn show(x: a) -> String where a: Display { - x.display() + "{x}" } fn main() { println(D { n: 1 }) println([D { n: 1 }]) println("{D { n: 1 }}") - println(D { n: 1 }.display()) + println(string.from(D { n: 1 })) println(show(D { n: 2 })) - println(D.display(D { n: 3 })) + println(string.from(D { n: 3 })) println(string.from(D { n: 4 })) } diff --git a/tests/golden/typecheck/display/display_impl__an_empty_impl_lacks_its_method.silt b/tests/golden/typecheck/display/display_impl__an_empty_impl_lacks_its_method.silt index e3844dc65..7b3ad7bc5 100644 --- a/tests/golden/typecheck/display/display_impl__an_empty_impl_lacks_its_method.silt +++ b/tests/golden/typecheck/display/display_impl__an_empty_impl_lacks_its_method.silt @@ -20,15 +20,15 @@ type F { trait Display for F {} fn show(x: a) -> String where a: Display { - x.display() + "{x}" } fn main() { println(D { n: 1 }) println([D { n: 1 }]) - println(D { n: 1 }.display()) + println(string.from(D { n: 1 })) println(show(D { n: 2 })) - println(D.display(D { n: 3 })) + println(string.from(D { n: 3 })) + println(string.from(F { f: { x -> x } })) println(string.from(F { f: { x -> x } })) - println(F { f: { x -> x } }.display()) } diff --git a/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__channel.silt b/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__channel.silt index a98b45b54..5b61085ea 100644 --- a/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__channel.silt +++ b/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__channel.silt @@ -4,7 +4,7 @@ -- stderr-contains: 'Channel' -- stderr-not-contains: required for string interpolation import channel -fn show(x: a) -> String where a: Display { x.display() } +fn show(x: a) -> String where a: Display { "{x}" } fn main() { let c = channel.new(1) println(show(c)) diff --git a/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__display_values_still_work.silt b/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__display_values_still_work.silt index 93330ae43..616b9888f 100644 --- a/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__display_values_still_work.silt +++ b/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__display_values_still_work.silt @@ -5,7 +5,7 @@ -- stdout-contains: P { import int type P { name: String, age: Int } -fn show(x: a) -> String where a: Display { x.display() } +fn show(x: a) -> String where a: Display { "{x}" } fn main() { println(show(42)) println(show("hi")) diff --git a/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__lambda.silt b/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__lambda.silt index 8a31c9387..2b43216c0 100644 --- a/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__lambda.silt +++ b/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__lambda.silt @@ -3,5 +3,5 @@ -- stderr-contains: does not implement trait 'Display' -- stderr-contains: 'Fn' -- stderr-not-contains: required for string interpolation -fn show(x: a) -> String where a: Display { x.display() } +fn show(x: a) -> String where a: Display { "{x}" } fn main() { println(show({ y -> y })) } diff --git a/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__list_of_fn_rejected.silt b/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__list_of_fn_rejected.silt index 0fe935d55..f0ec6e5de 100644 --- a/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__list_of_fn_rejected.silt +++ b/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__list_of_fn_rejected.silt @@ -5,5 +5,5 @@ -- a list of functions has none, as for `println`. fn main() { let f = { y -> y } - println([f].display()) + println("{[f]}") } diff --git a/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__task_handle.silt b/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__task_handle.silt index 90e6707d5..c29725e2a 100644 --- a/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__task_handle.silt +++ b/tests/golden/typecheck/display/round101_polymorphic_display_method_gate__task_handle.silt @@ -4,7 +4,7 @@ -- stderr-contains: 'task.Handle' -- stderr-not-contains: required for string interpolation import task -fn show(x: a) -> String where a: Display { x.display() } +fn show(x: a) -> String where a: Display { "{x}" } fn main() { let h = task.spawn({ -> 42 }) println(show(h)) diff --git a/tests/golden/typecheck/display/round74_display_eq_message_runtime__io_error_three_forms_agree.silt b/tests/golden/typecheck/display/round74_display_eq_message_runtime__io_error_three_forms_agree.silt index 9050b609e..b989c3c94 100644 --- a/tests/golden/typecheck/display/round74_display_eq_message_runtime__io_error_three_forms_agree.silt +++ b/tests/golden/typecheck/display/round74_display_eq_message_runtime__io_error_three_forms_agree.silt @@ -5,8 +5,8 @@ fn main() { Ok(_) -> () Err(e) -> { let display_form = "{e}" - let message_form = e.message() - let display_method_form = e.display() + let message_form = Error.message(e) + let display_method_form = "{e}" match display_form == message_form { true -> () false -> { diff --git a/tests/golden/typecheck/display/round74_display_eq_message_runtime__json_error_display_eq_message.silt b/tests/golden/typecheck/display/round74_display_eq_message_runtime__json_error_display_eq_message.silt index 637940794..2d6b0ac42 100644 --- a/tests/golden/typecheck/display/round74_display_eq_message_runtime__json_error_display_eq_message.silt +++ b/tests/golden/typecheck/display/round74_display_eq_message_runtime__json_error_display_eq_message.silt @@ -4,8 +4,8 @@ fn main() { match json.parse("not valid json at all", String) { Ok(_) -> () Err(e) -> { - let display_method_form = e.display() - let message_form = e.message() + let display_method_form = "{e}" + let message_form = Error.message(e) match display_method_form == message_form { true -> println("EQUIV") false -> { diff --git a/tests/golden/typecheck/display/round74_display_eq_message_runtime__user_enum_keeps_constructor_form.silt b/tests/golden/typecheck/display/round74_display_eq_message_runtime__user_enum_keeps_constructor_form.silt index d3abbd5ba..c51c35871 100644 --- a/tests/golden/typecheck/display/round74_display_eq_message_runtime__user_enum_keeps_constructor_form.silt +++ b/tests/golden/typecheck/display/round74_display_eq_message_runtime__user_enum_keeps_constructor_form.silt @@ -2,5 +2,5 @@ type Color { Red, Green(Int), Blue } fn main() { let c = Green(42) - println(c.display()) + println("{c}") } diff --git a/tests/golden/typecheck/display/texts__an_anonymous_record_is_written_without_a_tag.silt b/tests/golden/typecheck/display/texts__an_anonymous_record_is_written_without_a_tag.silt index 66abd9681..c9d36238a 100644 --- a/tests/golden/typecheck/display/texts__an_anonymous_record_is_written_without_a_tag.silt +++ b/tests/golden/typecheck/display/texts__an_anonymous_record_is_written_without_a_tag.silt @@ -18,10 +18,10 @@ fn main() { println([r]) println(io.inspect(r)) println(string.from(r)) - println(r.display()) - println(r.equal(r)) - println(r.equal({ b: 2, a: P { z: 1, a: 2 } })) - println(r.hash() == r.hash()) + println("{r}") + println(r == r) + println(r == { b: 2, a: P { z: 1, a: 2 } }) + println(Hash.hash(r) == Hash.hash(r)) println(io.inspect(P { z: 1, a: 2 })) println(io.inspect([P { z: 1, a: 2 }])) println(#{ r: 1 }) diff --git a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__compare_method_int_lists.silt b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__compare_method_int_lists.silt index 26e2725ef..b82a88a12 100644 --- a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__compare_method_int_lists.silt +++ b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__compare_method_int_lists.silt @@ -1,3 +1,3 @@ -- Positive control: `.compare()` on Int lists gives -1. -fn cmpm(a: t, b: t) -> Int where t: Compare { a.compare(b) } +fn cmpm(a: t, b: t) -> Int where t: Compare { Compare.compare(a, b) } fn main() { println(cmpm([1, 2], [3, 4])) } diff --git a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__concrete_hash_fn_list.silt b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__concrete_hash_fn_list.silt index 69589fd6b..9e60ba9f1 100644 --- a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__concrete_hash_fn_list.silt +++ b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__concrete_hash_fn_list.silt @@ -3,5 +3,5 @@ -- stderr-contains: error[type]: type 'List(Fn(_) -> _)' does not implement trait 'Hash': element is of type 'Fn(_) -> _', which does not fn main() { let xs = [{ y -> y }] - println(xs.hash()) + println(Hash.hash(xs)) } diff --git a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__concrete_hash_tuple_and_string.silt b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__concrete_hash_tuple_and_string.silt index 8a9fc3dc3..cd3ae4a11 100644 --- a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__concrete_hash_tuple_and_string.silt +++ b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__concrete_hash_tuple_and_string.silt @@ -1,2 +1,2 @@ -- Positive control: equal tuples and strings hash equal. -fn main() { println((1, "a").hash() == (1, "a").hash() && "abc".hash() == "abc".hash()) } +fn main() { println(Hash.hash((1, "a")) == Hash.hash((1, "a")) && Hash.hash("abc") == Hash.hash("abc")) } diff --git a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_compare_method_fn_lists.silt b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_compare_method_fn_lists.silt index ed133218e..d635cbb14 100644 --- a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_compare_method_fn_lists.silt +++ b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_compare_method_fn_lists.silt @@ -1,7 +1,7 @@ -- `.compare()` through a polymorphic wrapper on lists of functions fails. -- exit: 1 -- stderr-contains: error[type]: type 'List(Fn(_) -> _)' does not implement trait 'Compare': element is of type 'Fn(_) -> _', which does not -fn cmpm(a: t, b: t) -> Int where t: Compare { a.compare(b) } +fn cmpm(a: t, b: t) -> Int where t: Compare { Compare.compare(a, b) } fn main() { println(cmpm([{ y -> y }], [{ y -> y }])) } diff --git a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_equal_method_fn_lists.silt b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_equal_method_fn_lists.silt index fb672dd62..492fdacc3 100644 --- a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_equal_method_fn_lists.silt +++ b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_equal_method_fn_lists.silt @@ -1,7 +1,7 @@ -- `.equal()` through a polymorphic wrapper on lists of functions fails. -- exit: 1 -- stderr-contains: error[type]: type 'List(Fn(_) -> _)' does not implement trait 'Equal': element is of type 'Fn(_) -> _', which does not -fn eqm(a: t, b: t) -> Bool where t: Equal { a.equal(b) } +fn eqm(a: t, b: t) -> Bool where t: Equal { a == b } fn main() { println(eqm([{ y -> y }], [{ y -> y }])) } diff --git a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_fn_lists.silt b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_fn_lists.silt index 757bf190f..f93acd78d 100644 --- a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_fn_lists.silt +++ b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_fn_lists.silt @@ -1,7 +1,7 @@ -- `.hash()` through a polymorphic wrapper on lists of functions fails. -- exit: 1 -- stderr-contains: error[type]: type 'List(Fn(_) -> _)' does not implement trait 'Hash': element is of type 'Fn(_) -> _', which does not -fn h(a: x) -> Int where x: Hash { a.hash() } +fn h(a: x) -> Int where x: Hash { Hash.hash(a) } fn main() { println(h([{ y -> y }]) == h([{ z -> z * 99 }])) } diff --git a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_fn_tuples.silt b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_fn_tuples.silt index 7c1903b16..3be032b2b 100644 --- a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_fn_tuples.silt +++ b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_fn_tuples.silt @@ -1,7 +1,7 @@ -- `.hash()` through a polymorphic wrapper on tuples holding functions fails. -- exit: 1 -- stderr-contains: error[type]: type '(Fn(_) -> _, Int)' does not implement trait 'Hash': part #1 is of type 'Fn(_) -> _', which does not -fn h(a: x) -> Int where x: Hash { a.hash() } +fn h(a: x) -> Int where x: Hash { Hash.hash(a) } fn main() { println(h(({ y -> y }, 1)) == h(({ z -> z + 5 }, 1))) } diff --git a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_int_lists.silt b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_int_lists.silt index 0ca7e8ef8..2279e1b85 100644 --- a/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_int_lists.silt +++ b/tests/golden/typecheck/fn_compare/container_fn_compare_runtime_gate__polymorphic_hash_int_lists.silt @@ -1,3 +1,3 @@ -- Positive control: equal Int lists hash equal. -fn h(a: x) -> Int where x: Hash { a.hash() } +fn h(a: x) -> Int where x: Hash { Hash.hash(a) } fn main() { println(h([1, 2, 3]) == h([1, 2, 3])) } diff --git a/tests/golden/typecheck/hashing/round74_hash_eq_ord_contract__list_range_hash_eq.silt b/tests/golden/typecheck/hashing/round74_hash_eq_ord_contract__list_range_hash_eq.silt index 15a166877..80d674379 100644 --- a/tests/golden/typecheck/hashing/round74_hash_eq_ord_contract__list_range_hash_eq.silt +++ b/tests/golden/typecheck/hashing/round74_hash_eq_ord_contract__list_range_hash_eq.silt @@ -4,5 +4,5 @@ fn main() { let a: List(Int) = [1, 2, 3] let b: List(Int) = 1..3 println(a == b) - println(a.hash() == b.hash()) + println(Hash.hash(a) == Hash.hash(b)) } diff --git a/tests/golden/typecheck/inference/closure_params_from_expected__builtin_callee.silt b/tests/golden/typecheck/inference/closure_params_from_expected__builtin_callee.silt index 8b19a729f..36b811412 100644 --- a/tests/golden/typecheck/inference/closure_params_from_expected__builtin_callee.silt +++ b/tests/golden/typecheck/inference/closure_params_from_expected__builtin_callee.silt @@ -1,6 +1,6 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: unknown method 'missing' on type Int +-- stderr-contains: error[type]: type 'Int' has no field 'missing' -- The closure's parameter is the list's element type, known from the -- argument before it. import list diff --git a/tests/golden/typecheck/inference/closure_params_from_expected__method_result.silt b/tests/golden/typecheck/inference/closure_params_from_expected__method_result.silt index 02d1cda97..278e9dcc0 100644 --- a/tests/golden/typecheck/inference/closure_params_from_expected__method_result.silt +++ b/tests/golden/typecheck/inference/closure_params_from_expected__method_result.silt @@ -6,4 +6,4 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } fn apply(f: Fn(Int) -> Int, x: Int) -> Int { f(x) } -fn main() { println(apply({ n -> n.greet() }, 3)) } +fn main() { println(apply({ n -> Greet.greet(n) }, 3)) } diff --git a/tests/golden/typecheck/inference/closure_params_from_expected__unknown_field.silt b/tests/golden/typecheck/inference/closure_params_from_expected__unknown_field.silt index 62a5dc3ed..e5d9b6a12 100644 --- a/tests/golden/typecheck/inference/closure_params_from_expected__unknown_field.silt +++ b/tests/golden/typecheck/inference/closure_params_from_expected__unknown_field.silt @@ -1,6 +1,6 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: unknown field or method 'nam' on type P +-- stderr-contains: error[type]: type 'P' has no field 'nam' -- A closure literal passed to a function has the parameter types the -- function expects before its body is checked: `p` is a `P` at `p.nam`. type P { name: String } diff --git a/tests/golden/typecheck/inference/deferred__bound_on_outer_let_checked_when_decided.silt b/tests/golden/typecheck/inference/deferred__bound_on_outer_let_checked_when_decided.silt index b4e80730d..6c965d4a9 100644 --- a/tests/golden/typecheck/inference/deferred__bound_on_outer_let_checked_when_decided.silt +++ b/tests/golden/typecheck/inference/deferred__bound_on_outer_let_checked_when_decided.silt @@ -7,7 +7,7 @@ import channel trait Loud { fn loud(self) -> String } trait Loud for Int { fn loud(self) -> String { "int!" } } -fn shout(x: a) -> String where a: Loud { x.loud() } +fn shout(x: a) -> String where a: Loud { Loud.loud(x) } let ch = channel.new(4) fn drain() { match channel.receive(ch) { diff --git a/tests/golden/typecheck/inference/deferred__operator_method_and_question_on_outer_let_checked_when_decided.silt b/tests/golden/typecheck/inference/deferred__operator_method_and_question_on_outer_let_checked_when_decided.silt index 58b493f7b..dee3fec6b 100644 --- a/tests/golden/typecheck/inference/deferred__operator_method_and_question_on_outer_let_checked_when_decided.silt +++ b/tests/golden/typecheck/inference/deferred__operator_method_and_question_on_outer_let_checked_when_decided.silt @@ -1,10 +1,10 @@ -- cmd: check -- exit: 1 --- An operator, a method call and `?` on a value whose type a top-level +-- An operator, a field call and `?` on a value whose type a top-level -- `let` leaves unknown are checked when a later function decides it. -- stderr-contains: operator '*' requires Int or Float, got 'String' -- stderr-contains: requires Int or Float, got 'String' --- stderr-contains: unknown field or method 'loud' on type String +-- stderr-contains: type 'String' has no field 'loud' -- stderr-contains: '?' operator requires Result or Option type, got 'String' import channel trait Loud { fn loud(self) -> String } diff --git a/tests/golden/typecheck/inference/infer_order__bound_inferred_through_wrappers.silt b/tests/golden/typecheck/inference/infer_order__bound_inferred_through_wrappers.silt index bc42ad2ae..8a274fb52 100644 --- a/tests/golden/typecheck/inference/infer_order__bound_inferred_through_wrappers.silt +++ b/tests/golden/typecheck/inference/infer_order__bound_inferred_through_wrappers.silt @@ -7,7 +7,7 @@ -- stderr-not-contains: enclosing function trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn wrap(x) { hello(x) } fn wrap2(x) { wrap(x) } fn main() { diff --git a/tests/golden/typecheck/inference/infer_order__group_functions_share_annotation_variables.silt b/tests/golden/typecheck/inference/infer_order__group_functions_share_annotation_variables.silt index af85b0dc9..95e416b82 100644 --- a/tests/golden/typecheck/inference/infer_order__group_functions_share_annotation_variables.silt +++ b/tests/golden/typecheck/inference/infer_order__group_functions_share_annotation_variables.silt @@ -30,7 +30,7 @@ fn size_all(ts: List(Tree(b))) { } fn say(x: a, n: Int) where a: Loud { match n { - 0 -> x.loud() + 0 -> Loud.loud(x) _ -> echo(x, n - 1) } } diff --git a/tests/golden/typecheck/inference/infer_order__group_keeps_one_functions_variables_apart.silt b/tests/golden/typecheck/inference/infer_order__group_keeps_one_functions_variables_apart.silt index b276b4f81..4305c959c 100644 --- a/tests/golden/typecheck/inference/infer_order__group_keeps_one_functions_variables_apart.silt +++ b/tests/golden/typecheck/inference/infer_order__group_keeps_one_functions_variables_apart.silt @@ -16,7 +16,7 @@ fn pair(x: a, y: b, n: Int) { fn flip(u: c, v: c, n: Int) { pair(u, v, n) } fn say(x: a, n: Int) where a: Loud { match n { - 0 -> x.loud() + 0 -> Loud.loud(x) _ -> echo(x, n - 1) } } diff --git a/tests/golden/typecheck/inference/infer_order__group_member_owes_neighbours_bound.silt b/tests/golden/typecheck/inference/infer_order__group_member_owes_neighbours_bound.silt index 56fac5646..08bdd544f 100644 --- a/tests/golden/typecheck/inference/infer_order__group_member_owes_neighbours_bound.silt +++ b/tests/golden/typecheck/inference/infer_order__group_member_owes_neighbours_bound.silt @@ -8,7 +8,7 @@ trait Loud { fn loud(self) -> String } trait Loud for Int { fn loud(self) -> String { "int!" } } fn shout(x: a, n) where a: Loud { match n { - 0 -> x.loud() + 0 -> Loud.loud(x) _ -> relay(x, n - 1) } } diff --git a/tests/golden/typecheck/inference/infer_order__wrappers_of_bounded_fn_run.silt b/tests/golden/typecheck/inference/infer_order__wrappers_of_bounded_fn_run.silt index fd8585d01..962446eb8 100644 --- a/tests/golden/typecheck/inference/infer_order__wrappers_of_bounded_fn_run.silt +++ b/tests/golden/typecheck/inference/infer_order__wrappers_of_bounded_fn_run.silt @@ -2,7 +2,7 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Greet for Bool { fn greet(self) -> String { "bool" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn wrap(x) { hello(x) } fn wrap2(x) { wrap(x) } fn main() { diff --git a/tests/golden/typecheck/inference/rigid__annotated_variable_needs_declared_bound.silt b/tests/golden/typecheck/inference/rigid__annotated_variable_needs_declared_bound.silt index 0e097dcda..c003a7b84 100644 --- a/tests/golden/typecheck/inference/rigid__annotated_variable_needs_declared_bound.silt +++ b/tests/golden/typecheck/inference/rigid__annotated_variable_needs_declared_bound.silt @@ -3,11 +3,10 @@ -- A parameter annotated with a type variable has the bounds its `where` -- clauses declare and no other, also when the return type is left out. -- stderr-contains: error[type]: type variable `b` is not known to implement trait 'Greet', which 'hello' needs --- stderr-contains: no field or method 'greet' on a value of type `c`: the type variable has no trait bound --- stderr-contains: add `where c: SomeTrait` +-- stderr-contains: error[type]: type 'c' has no field 'greet' trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn partly(x: b) { hello(x) } fn method(x: c) -> String { x.greet() } fn main() { println(partly(1)) } diff --git a/tests/golden/typecheck/inference/select__a_method_is_not_a_value.silt b/tests/golden/typecheck/inference/select__a_method_is_not_a_value.silt index 04d854165..cbf22c1e5 100644 --- a/tests/golden/typecheck/inference/select__a_method_is_not_a_value.silt +++ b/tests/golden/typecheck/inference/select__a_method_is_not_a_value.silt @@ -1,7 +1,9 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: method 'add' is not a value: a method is called --- stderr-contains: help: call it, `x.add(..)`, or pass a closure that does, `{ x -> x.add(..) }` +-- stderr-contains: error[type]: type 'Int' has no field 'add' +-- stderr-contains: help: `add` is a method of trait `Adder`: call it as `Adder.add(x, ..)` +-- A dot after a value is a field, called or not: a trait's method is +-- taken through its trait (`Adder.add`). trait Adder { fn add(self, x: Int) -> Int } trait Adder for Int { fn add(self, x: Int) -> Int { self + x } } fn main() { diff --git a/tests/golden/typecheck/inference/select__method_result_is_the_methods.silt b/tests/golden/typecheck/inference/select__method_result_is_the_methods.silt index 81d895bca..e3f977f39 100644 --- a/tests/golden/typecheck/inference/select__method_result_is_the_methods.silt +++ b/tests/golden/typecheck/inference/select__method_result_is_the_methods.silt @@ -5,7 +5,7 @@ -- does, the receiver's type. trait Same { fn same(self) -> Self } trait Same for String { fn same(self) -> Self { self } } -fn coerce(x) { x.same() } +fn coerce(x) { Same.same(x) } fn main() { let n: Int = coerce("not an int") println(n) diff --git a/tests/golden/typecheck/inference/select__one_trait_bound_is_owed.silt b/tests/golden/typecheck/inference/select__one_trait_bound_is_owed.silt index 96a7e8b35..25ef33ba5 100644 --- a/tests/golden/typecheck/inference/select__one_trait_bound_is_owed.silt +++ b/tests/golden/typecheck/inference/select__one_trait_bound_is_owed.silt @@ -3,7 +3,7 @@ -- stderr-contains: error[type]: type 'String' does not implement trait 'Greet' trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn g(x) { x.greet() } +fn g(x) { Greet.greet(x) } fn main() { println(g(1)) println(g("s")) diff --git a/tests/golden/typecheck/inference/select__one_trait_bounds_the_receiver.silt b/tests/golden/typecheck/inference/select__one_trait_bounds_the_receiver.silt index 41ef72d06..3aeae1e3f 100644 --- a/tests/golden/typecheck/inference/select__one_trait_bounds_the_receiver.silt +++ b/tests/golden/typecheck/inference/select__one_trait_bounds_the_receiver.silt @@ -3,10 +3,10 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Greet for Bool { fn greet(self) -> String { "bool" } } -fn g(x) { x.greet() } +fn g(x) { Greet.greet(x) } fn main() { println(g(1)) println(g(true)) - let h = { y -> "{y.greet()}!" } + let h = { y -> "{Greet.greet(y)}!" } println(h(2)) } diff --git a/tests/golden/typecheck/inference/select__receiver_decided_later.silt b/tests/golden/typecheck/inference/select__receiver_decided_later.silt index d825ffb67..8e3c3eb18 100644 --- a/tests/golden/typecheck/inference/select__receiver_decided_later.silt +++ b/tests/golden/typecheck/inference/select__receiver_decided_later.silt @@ -7,7 +7,7 @@ fn main() { let ch = channel.new(1) let f = { -> match channel.try_receive(ch) { - channel.Message(m) -> m.greet() + channel.Message(m) -> Greet.greet(m) _ -> "none" } } diff --git a/tests/golden/typecheck/init_order/init_order__a_call_into_another_module/other.silt b/tests/golden/typecheck/init_order/init_order__a_call_into_another_module/other.silt index 72adc9b53..bf5aebe89 100644 --- a/tests/golden/typecheck/init_order/init_order__a_call_into_another_module/other.silt +++ b/tests/golden/typecheck/init_order/init_order__a_call_into_another_module/other.silt @@ -1,3 +1,3 @@ pub trait Greet { fn greet(self) -> String } -pub fn run(x: a) -> String where a: Greet { x.greet() } +pub fn run(x: a) -> String where a: Greet { Greet.greet(x) } pub fn load() -> Int { 1 } diff --git a/tests/golden/typecheck/init_order/init_order__a_display_impl_that_reads_the_let_it_shows_for.silt b/tests/golden/typecheck/init_order/init_order__a_display_impl_that_reads_the_let_it_shows_for.silt index 8a30a6b3b..6c6142d6d 100644 --- a/tests/golden/typecheck/init_order/init_order__a_display_impl_that_reads_the_let_it_shows_for.silt +++ b/tests/golden/typecheck/init_order/init_order__a_display_impl_that_reads_the_let_it_shows_for.silt @@ -32,7 +32,7 @@ type Holder { w: Wrap, } -let label = Some(Holder { w: Wrap { t: 1 } }).display() +let label = string.from(Some(Holder { w: Wrap { t: 1 } })) fn main() { println(total) diff --git a/tests/golden/typecheck/init_order/init_order__a_function_shows_what_it_is_named_at__an_own_type.silt b/tests/golden/typecheck/init_order/init_order__a_function_shows_what_it_is_named_at__an_own_type.silt index 6f9718c2e..f15f41200 100644 --- a/tests/golden/typecheck/init_order/init_order__a_function_shows_what_it_is_named_at__an_own_type.silt +++ b/tests/golden/typecheck/init_order/init_order__a_function_shows_what_it_is_named_at__an_own_type.silt @@ -16,7 +16,7 @@ fn label(x: a) -> String where a: Display { } fn dlabel(x: a) -> String where a: Display { - x.display() + "{x}" } fn slabel(x: a) -> String where a: Display { diff --git a/tests/golden/typecheck/init_order/init_order__a_let_that_reaches_itself.silt b/tests/golden/typecheck/init_order/init_order__a_let_that_reaches_itself.silt index 29576abd7..ee0cd9b4c 100644 --- a/tests/golden/typecheck/init_order/init_order__a_let_that_reaches_itself.silt +++ b/tests/golden/typecheck/init_order/init_order__a_let_that_reaches_itself.silt @@ -15,7 +15,7 @@ let a = f() fn f() -> Int { g() + 1 } fn g() -> Int { b } let b = a + 1 -let table = P { n: 1 }.size() +let table = Size.size(P { n: 1 }) let own = own + 1 let fine = 3 fn main() { println(a + table + own + fine) } diff --git a/tests/golden/typecheck/init_order/init_order__lets_run_after_what_they_reach.silt b/tests/golden/typecheck/init_order/init_order__lets_run_after_what_they_reach.silt index 79497ed2c..8e7a577b2 100644 --- a/tests/golden/typecheck/init_order/init_order__lets_run_after_what_they_reach.silt +++ b/tests/golden/typecheck/init_order/init_order__lets_run_after_what_they_reach.silt @@ -7,7 +7,7 @@ import list type P { n: Int } trait Get { fn get(self) -> Int - fn twice(self) -> Int { self.get() * 2 } + fn twice(self) -> Int { Get.get(self) * 2 } } trait Get for P { fn get(self) -> Int { self.n + base } } let a = b + 1 @@ -18,7 +18,7 @@ let b = { } let e = { println("e") - P { n: 1 }.twice() + Get.twice(P { n: 1 }) } let base = { println("base") diff --git a/tests/golden/typecheck/init_order/init_order__outside_code__a_builtin_default_method.silt b/tests/golden/typecheck/init_order/init_order__outside_code__a_builtin_default_method.silt index b3817e549..3bde8be28 100644 --- a/tests/golden/typecheck/init_order/init_order__outside_code__a_builtin_default_method.silt +++ b/tests/golden/typecheck/init_order/init_order__outside_code__a_builtin_default_method.silt @@ -7,7 +7,7 @@ type MyErr { code: Int } trait Display for MyErr { fn display(self) -> String { "E{self.code}/{late}" } } trait Error for MyErr { } -let m = MyErr { code: 1 }.message() +let m = Error.message(MyErr { code: 1 }) let late = { println("late") 5 diff --git a/tests/golden/typecheck/init_order/init_order__outside_code__b_generic_wrapper/other.silt b/tests/golden/typecheck/init_order/init_order__outside_code__b_generic_wrapper/other.silt index b3dfa812d..3f79fecc5 100644 --- a/tests/golden/typecheck/init_order/init_order__outside_code__b_generic_wrapper/other.silt +++ b/tests/golden/typecheck/init_order/init_order__outside_code__b_generic_wrapper/other.silt @@ -1,3 +1,3 @@ pub trait Greet { fn greet(self) -> String } -pub fn run(x: a) -> String where a: Greet { x.greet() } +pub fn run(x: a) -> String where a: Greet { Greet.greet(x) } pub fn each(xs: List(a)) -> List(String) where a: Greet { [] } diff --git a/tests/golden/typecheck/init_order/init_order__outside_code__c_default_method_of_another_module/main.silt b/tests/golden/typecheck/init_order/init_order__outside_code__c_default_method_of_another_module/main.silt index d5ada7c84..787b2cfc5 100644 --- a/tests/golden/typecheck/init_order/init_order__outside_code__c_default_method_of_another_module/main.silt +++ b/tests/golden/typecheck/init_order/init_order__outside_code__c_default_method_of_another_module/main.silt @@ -6,7 +6,7 @@ import other type P { n: Int } trait other.Tag for P { fn tag(self) -> String { "main.P.tag {late}" } } -fn tg(x: a) -> String where a: other.Tag { x.tagged() } +fn tg(x: a) -> String where a: other.Tag { other.Tag.tagged(x) } let v = tg(P { n: 1 }) let late = { println("late") diff --git a/tests/golden/typecheck/init_order/init_order__outside_code__c_default_method_of_another_module/other.silt b/tests/golden/typecheck/init_order/init_order__outside_code__c_default_method_of_another_module/other.silt index 153cf0b33..b30cf6dbc 100644 --- a/tests/golden/typecheck/init_order/init_order__outside_code__c_default_method_of_another_module/other.silt +++ b/tests/golden/typecheck/init_order/init_order__outside_code__c_default_method_of_another_module/other.silt @@ -3,10 +3,10 @@ pub type E { X, Y(Int) } pub trait Name { fn name(self) -> String } trait Name for P { fn name(self) -> String { "other.P" } } trait Name for E { fn name(self) -> String { "other.E" } } -pub fn dyn_name(x: a) -> String where a: Name { x.name() } +pub fn dyn_name(x: a) -> String where a: Name { Name.name(x) } pub trait Tag { fn tag(self) -> String - fn tagged(self) -> String { "<{self.tag()}>" } + fn tagged(self) -> String { "<{Tag.tag(self)}>" } } trait Tag for P { fn tag(self) -> String { "other.P.tag" } } pub fn mk() -> P { P { n: 1 } } diff --git a/tests/golden/typecheck/init_order/init_order__outside_code__d_argument_inside_a_generic_type/other.silt b/tests/golden/typecheck/init_order/init_order__outside_code__d_argument_inside_a_generic_type/other.silt index e005dba0d..44b15f926 100644 --- a/tests/golden/typecheck/init_order/init_order__outside_code__d_argument_inside_a_generic_type/other.silt +++ b/tests/golden/typecheck/init_order/init_order__outside_code__d_argument_inside_a_generic_type/other.silt @@ -2,5 +2,5 @@ pub fn call(f: Fn() -> a) -> a { f() } pub fn apply(f: Fn(a) -> b, x: a) -> b { f(x) } pub type Box(a) { item: a } pub trait Greet { fn greet(self) -> String } -pub fn greet_box(b: Box(a)) -> String where a: Greet { b.item.greet() } -pub fn greet2(x: a) -> String where a: Greet { x.greet() } +pub fn greet_box(b: Box(a)) -> String where a: Greet { Greet.greet(b.item) } +pub fn greet2(x: a) -> String where a: Greet { Greet.greet(x) } diff --git a/tests/golden/typecheck/init_order/init_order__outside_code__e_function_of_another_module_in_a_let/other.silt b/tests/golden/typecheck/init_order/init_order__outside_code__e_function_of_another_module_in_a_let/other.silt index e005dba0d..44b15f926 100644 --- a/tests/golden/typecheck/init_order/init_order__outside_code__e_function_of_another_module_in_a_let/other.silt +++ b/tests/golden/typecheck/init_order/init_order__outside_code__e_function_of_another_module_in_a_let/other.silt @@ -2,5 +2,5 @@ pub fn call(f: Fn() -> a) -> a { f() } pub fn apply(f: Fn(a) -> b, x: a) -> b { f(x) } pub type Box(a) { item: a } pub trait Greet { fn greet(self) -> String } -pub fn greet_box(b: Box(a)) -> String where a: Greet { b.item.greet() } -pub fn greet2(x: a) -> String where a: Greet { x.greet() } +pub fn greet_box(b: Box(a)) -> String where a: Greet { Greet.greet(b.item) } +pub fn greet2(x: a) -> String where a: Greet { Greet.greet(x) } diff --git a/tests/golden/typecheck/init_order/init_order__outside_code__f_handed_to_a_builtin_function/other.silt b/tests/golden/typecheck/init_order/init_order__outside_code__f_handed_to_a_builtin_function/other.silt index e005dba0d..44b15f926 100644 --- a/tests/golden/typecheck/init_order/init_order__outside_code__f_handed_to_a_builtin_function/other.silt +++ b/tests/golden/typecheck/init_order/init_order__outside_code__f_handed_to_a_builtin_function/other.silt @@ -2,5 +2,5 @@ pub fn call(f: Fn() -> a) -> a { f() } pub fn apply(f: Fn(a) -> b, x: a) -> b { f(x) } pub type Box(a) { item: a } pub trait Greet { fn greet(self) -> String } -pub fn greet_box(b: Box(a)) -> String where a: Greet { b.item.greet() } -pub fn greet2(x: a) -> String where a: Greet { x.greet() } +pub fn greet_box(b: Box(a)) -> String where a: Greet { Greet.greet(b.item) } +pub fn greet2(x: a) -> String where a: Greet { Greet.greet(x) } diff --git a/tests/golden/typecheck/init_order/init_order__outside_code__g_handed_to_a_function_of_the_module/other.silt b/tests/golden/typecheck/init_order/init_order__outside_code__g_handed_to_a_function_of_the_module/other.silt index e005dba0d..44b15f926 100644 --- a/tests/golden/typecheck/init_order/init_order__outside_code__g_handed_to_a_function_of_the_module/other.silt +++ b/tests/golden/typecheck/init_order/init_order__outside_code__g_handed_to_a_function_of_the_module/other.silt @@ -2,5 +2,5 @@ pub fn call(f: Fn() -> a) -> a { f() } pub fn apply(f: Fn(a) -> b, x: a) -> b { f(x) } pub type Box(a) { item: a } pub trait Greet { fn greet(self) -> String } -pub fn greet_box(b: Box(a)) -> String where a: Greet { b.item.greet() } -pub fn greet2(x: a) -> String where a: Greet { x.greet() } +pub fn greet_box(b: Box(a)) -> String where a: Greet { Greet.greet(b.item) } +pub fn greet2(x: a) -> String where a: Greet { Greet.greet(x) } diff --git a/tests/golden/typecheck/init_order/init_order__outside_code__h_bound_in_a_block_or_closure/other.silt b/tests/golden/typecheck/init_order/init_order__outside_code__h_bound_in_a_block_or_closure/other.silt index e005dba0d..44b15f926 100644 --- a/tests/golden/typecheck/init_order/init_order__outside_code__h_bound_in_a_block_or_closure/other.silt +++ b/tests/golden/typecheck/init_order/init_order__outside_code__h_bound_in_a_block_or_closure/other.silt @@ -2,5 +2,5 @@ pub fn call(f: Fn() -> a) -> a { f() } pub fn apply(f: Fn(a) -> b, x: a) -> b { f(x) } pub type Box(a) { item: a } pub trait Greet { fn greet(self) -> String } -pub fn greet_box(b: Box(a)) -> String where a: Greet { b.item.greet() } -pub fn greet2(x: a) -> String where a: Greet { x.greet() } +pub fn greet_box(b: Box(a)) -> String where a: Greet { Greet.greet(b.item) } +pub fn greet2(x: a) -> String where a: Greet { Greet.greet(x) } diff --git a/tests/golden/typecheck/init_order/init_order__outside_code__i_held_in_a_record_field/other.silt b/tests/golden/typecheck/init_order/init_order__outside_code__i_held_in_a_record_field/other.silt index e005dba0d..44b15f926 100644 --- a/tests/golden/typecheck/init_order/init_order__outside_code__i_held_in_a_record_field/other.silt +++ b/tests/golden/typecheck/init_order/init_order__outside_code__i_held_in_a_record_field/other.silt @@ -2,5 +2,5 @@ pub fn call(f: Fn() -> a) -> a { f() } pub fn apply(f: Fn(a) -> b, x: a) -> b { f(x) } pub type Box(a) { item: a } pub trait Greet { fn greet(self) -> String } -pub fn greet_box(b: Box(a)) -> String where a: Greet { b.item.greet() } -pub fn greet2(x: a) -> String where a: Greet { x.greet() } +pub fn greet_box(b: Box(a)) -> String where a: Greet { Greet.greet(b.item) } +pub fn greet2(x: a) -> String where a: Greet { Greet.greet(x) } diff --git a/tests/golden/typecheck/init_order/init_order__showing_a_value_reaches_its_display_impls.silt b/tests/golden/typecheck/init_order/init_order__showing_a_value_reaches_its_display_impls.silt index bf64596d4..8ea2dad82 100644 --- a/tests/golden/typecheck/init_order/init_order__showing_a_value_reaches_its_display_impls.silt +++ b/tests/golden/typecheck/init_order/init_order__showing_a_value_reaches_its_display_impls.silt @@ -30,7 +30,7 @@ let a = "{Temp { degrees: 1 }}" let b = string.from(Wrap { inner: [Temp { degrees: 2 }] }) -let c = Node(Leaf(Temp { degrees: 3 }), Leaf(Temp { degrees: 4 })).display() +let c = string.from(Node(Leaf(Temp { degrees: 3 }), Leaf(Temp { degrees: 4 }))) let d = [Some(Temp { degrees: 5 })] |> list.map(string.from) @@ -47,7 +47,7 @@ let f = show((Temp { degrees: 7 }, 1)) let plain = { println("plain") - "{[1, 2]} {3.display()}" + "{[1, 2]} {3}" } let unit = { diff --git a/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__a_default_method.silt b/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__a_default_method.silt index bc0784d7b..ce610813f 100644 --- a/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__a_default_method.silt +++ b/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__a_default_method.silt @@ -17,7 +17,7 @@ trait Container { type Item: Display fn first(self) -> Self::Item fn shown(self) -> String { - "first is {self.first()}" + "first is {Container.first(self)}" } } @@ -32,7 +32,7 @@ trait Container for Holder { } } -let a = Holder { t: T { n: 1 } }.shown() +let a = Container.shown(Holder { t: T { n: 1 } }) let unit = { println("unit") diff --git a/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__b_bounded_function.silt b/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__b_bounded_function.silt index a55528317..2d9c44558 100644 --- a/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__b_bounded_function.silt +++ b/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__b_bounded_function.silt @@ -30,7 +30,7 @@ trait Container for Holder { } fn shown(c: c) -> String where c: Container { - "first is {c.first()}" + "first is {Container.first(c)}" } let a = shown(Holder { t: T { n: 1 } }) diff --git a/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__c_inside_a_list.silt b/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__c_inside_a_list.silt index 1893c2e52..d81ca7cea 100644 --- a/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__c_inside_a_list.silt +++ b/tests/golden/typecheck/init_order/init_order__showing_an_associated_type__c_inside_a_list.silt @@ -18,10 +18,10 @@ trait Container { type Item: Display fn all(self) -> List(Self::Item) fn shown(self) -> String { - string.from(self.all()) + string.from(Container.all(self)) } fn shown2(self) -> String { - self.all().display() + "{Container.all(self)}" } } @@ -36,9 +36,9 @@ trait Container for Holder { } } -let a = Holder { t: T { n: 1 } }.shown() +let a = Container.shown(Holder { t: T { n: 1 } }) -let a2 = Holder { t: T { n: 2 } }.shown2() +let a2 = Container.shown2(Holder { t: T { n: 2 } }) let unit = { println("unit") diff --git a/tests/golden/typecheck/init_order/init_order__what_is_not_a_plain_value.silt b/tests/golden/typecheck/init_order/init_order__what_is_not_a_plain_value.silt index 0c807bf47..744eacf63 100644 --- a/tests/golden/typecheck/init_order/init_order__what_is_not_a_plain_value.silt +++ b/tests/golden/typecheck/init_order/init_order__what_is_not_a_plain_value.silt @@ -37,7 +37,7 @@ trait Label for Other { } fn lbl(x: a) -> String where a: Label { - x.label() + Label.label(x) } let version = lbl(Other { k: 1 }) @@ -67,7 +67,7 @@ type P { trait S { fn s(self) -> Int fn t(self) -> Int { - self.s() + 1 + S.s(self) + 1 } } @@ -77,7 +77,7 @@ trait S for P { } } -let (p, q) = (r, P { n: 1 }.t()) +let (p, q) = (r, S.t(P { n: 1 })) let r = 1 diff --git a/tests/golden/typecheck/modules/cross_module_inference__constrained_fn_satisfied/a.silt b/tests/golden/typecheck/modules/cross_module_inference__constrained_fn_satisfied/a.silt index a391d1379..3f436353e 100644 --- a/tests/golden/typecheck/modules/cross_module_inference__constrained_fn_satisfied/a.silt +++ b/tests/golden/typecheck/modules/cross_module_inference__constrained_fn_satisfied/a.silt @@ -1 +1 @@ -pub fn show(x: a) -> String where a: Display { x.display() } +pub fn show(x: a) -> String where a: Display { "{x}" } diff --git a/tests/golden/typecheck/modules/cross_module_inference__constrained_fn_unsatisfied/a.silt b/tests/golden/typecheck/modules/cross_module_inference__constrained_fn_unsatisfied/a.silt index e01479e45..4c7ce6cb1 100644 --- a/tests/golden/typecheck/modules/cross_module_inference__constrained_fn_unsatisfied/a.silt +++ b/tests/golden/typecheck/modules/cross_module_inference__constrained_fn_unsatisfied/a.silt @@ -2,4 +2,4 @@ pub trait Greet { fn greet(self) -> String } -pub fn announce(x: a) -> String where a: Greet { x.greet() } +pub fn announce(x: a) -> String where a: Greet { Greet.greet(x) } diff --git a/tests/golden/typecheck/modules/cross_module_inference__pub_trait_local_impl/main.silt b/tests/golden/typecheck/modules/cross_module_inference__pub_trait_local_impl/main.silt index 85c9955ae..0e04e451f 100644 --- a/tests/golden/typecheck/modules/cross_module_inference__pub_trait_local_impl/main.silt +++ b/tests/golden/typecheck/modules/cross_module_inference__pub_trait_local_impl/main.silt @@ -14,5 +14,5 @@ trait a.Describe for Box(t) where t: Display { } fn main() { - Wrap(42).describe() + a.Describe.describe(Wrap(42)) } diff --git a/tests/golden/typecheck/modules/cross_module_inference__pub_trait_pub_impl_consumer/main.silt b/tests/golden/typecheck/modules/cross_module_inference__pub_trait_pub_impl_consumer/main.silt index f3f92ab27..03d0a6a8d 100644 --- a/tests/golden/typecheck/modules/cross_module_inference__pub_trait_pub_impl_consumer/main.silt +++ b/tests/golden/typecheck/modules/cross_module_inference__pub_trait_pub_impl_consumer/main.silt @@ -3,7 +3,7 @@ -- stderr-not-contains: error import a -fn announce(x: a) -> String where a: a.Greet { x.greet() } +fn announce(x: a) -> String where a: a.Greet { a.Greet.greet(x) } fn main() { announce(7) diff --git a/tests/golden/typecheck/modules/impl_place__a_bounded_function_of_a_module_that_does_not_import_the_impl/x.silt b/tests/golden/typecheck/modules/impl_place__a_bounded_function_of_a_module_that_does_not_import_the_impl/x.silt index 83cd46a9d..c83420b0c 100644 --- a/tests/golden/typecheck/modules/impl_place__a_bounded_function_of_a_module_that_does_not_import_the_impl/x.silt +++ b/tests/golden/typecheck/modules/impl_place__a_bounded_function_of_a_module_that_does_not_import_the_impl/x.silt @@ -1,7 +1,7 @@ import t pub fn f(v: a) -> String where a: t.T { - "f: {v.m()}" + "f: {t.T.m(v)}" } pub fn shown(v: a) -> String where a: Display { diff --git a/tests/golden/typecheck/modules/impl_place__a_refused_display_impl_for_a_builtin_type.silt b/tests/golden/typecheck/modules/impl_place__a_refused_display_impl_for_a_builtin_type.silt index 875f9aec3..0ef9307af 100644 --- a/tests/golden/typecheck/modules/impl_place__a_refused_display_impl_for_a_builtin_type.silt +++ b/tests/golden/typecheck/modules/impl_place__a_refused_display_impl_for_a_builtin_type.silt @@ -6,7 +6,7 @@ trait Display for Int { } fn need_d(x: a) -> Int where a: Display { 1 } fn main() { - let _ = 1.display() + let _ = "{1}" let _ = "{1}" let _ = need_d(1) let _ = need_d([1]) diff --git a/tests/golden/typecheck/modules/impl_place__a_refused_display_impl_is_no_impl/main.silt b/tests/golden/typecheck/modules/impl_place__a_refused_display_impl_is_no_impl/main.silt index 1db7be60a..04d476f59 100644 --- a/tests/golden/typecheck/modules/impl_place__a_refused_display_impl_is_no_impl/main.silt +++ b/tests/golden/typecheck/modules/impl_place__a_refused_display_impl_is_no_impl/main.silt @@ -17,7 +17,7 @@ fn need_d(x: a) -> Int where a: Display { 1 } fn main() { let t = Tag { name: "m" } - let _ = t.display() + let _ = "{t}" let _ = "{t}" println(t) let _ = need_d(t) diff --git a/tests/golden/typecheck/modules/impl_place__an_impl_in_the_traits_module_for_a_type_of_a_third/early.silt b/tests/golden/typecheck/modules/impl_place__an_impl_in_the_traits_module_for_a_type_of_a_third/early.silt index 4acbbed99..f3f5a78df 100644 --- a/tests/golden/typecheck/modules/impl_place__an_impl_in_the_traits_module_for_a_type_of_a_third/early.silt +++ b/tests/golden/typecheck/modules/impl_place__an_impl_in_the_traits_module_for_a_type_of_a_third/early.silt @@ -3,6 +3,6 @@ import traits pub let first = traits.measure(shapes.unit_square()) -pub let second = shapes.Square { side: 2 }.told() +pub let second = traits.Area.told(shapes.Square { side: 2 }) -pub let third = 3.area() +pub let third = traits.Area.area(3) diff --git a/tests/golden/typecheck/modules/impl_place__an_impl_in_the_traits_module_for_a_type_of_a_third/traits.silt b/tests/golden/typecheck/modules/impl_place__an_impl_in_the_traits_module_for_a_type_of_a_third/traits.silt index 532c0b0a3..f6e84fe99 100644 --- a/tests/golden/typecheck/modules/impl_place__an_impl_in_the_traits_module_for_a_type_of_a_third/traits.silt +++ b/tests/golden/typecheck/modules/impl_place__an_impl_in_the_traits_module_for_a_type_of_a_third/traits.silt @@ -3,7 +3,7 @@ import shapes pub trait Area { fn area(self) -> Int fn told(self) -> String { - "{label}{self.area()}" + "{label}{Area.area(self)}" } } @@ -27,5 +27,5 @@ let scale = { let label = "area " pub fn measure(x: a) -> Int where a: Area { - x.area() + Area.area(x) } diff --git a/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/case.stderr b/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/case.stderr index b2106067c..b6a7741e9 100644 --- a/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/case.stderr +++ b/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/case.stderr @@ -1,5 +1,5 @@ error[type]: the impl of trait 'Display' for type 'types.Tag' is written in module 'main', which declares neither the trait nor the type; it may be written in module 'types', which declares the type - --> main.silt:10:1 + --> main.silt:11:1 | - 10 | trait Display for Tag { + 11 | trait Display for Tag { | ^^^^^^^^^^^^^^^^^^^^^^^ the impl of trait 'Display' for type 'types.Tag' is written in module 'main', which declares neither the trait nor the type; it may be written in module 'types', which declares the type diff --git a/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/early.silt b/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/early.silt index 7bd373fdd..e194bddb0 100644 --- a/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/early.silt +++ b/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/early.silt @@ -1,7 +1,8 @@ import types.{ Tag } +import string pub fn show(x: a) -> String where a: Display { - x.display() + "{x}" } -pub let text = Tag { name: "e" }.display() +pub let text = string.from(Tag { name: "e" }) pub let text2 = show(Tag { name: "e2" }) -pub let text3 = Tag.display(Tag { name: "e3" }) +pub let text3 = string.from(Tag { name: "e3" }) diff --git a/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/main.silt b/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/main.silt index 830b6c6d7..603e3b2e6 100644 --- a/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/main.silt +++ b/tests/golden/typecheck/modules/impl_place__m09_display_called_before_its_module_is_initialised/main.silt @@ -6,6 +6,7 @@ -- impl is the one error: the type keeps its structural Display. import early import types.{ Tag } +import string trait Display for Tag { fn display(self) -> String { @@ -19,6 +20,6 @@ fn main() { println(early.text) println(early.text2) println(early.text3) - println(Tag { name: "m" }.display()) + println(string.from(Tag { name: "m" })) println(early.show(Tag { name: "m2" })) } diff --git a/tests/golden/typecheck/modules/impl_place__m10_an_impl_that_reads_a_let_of_its_module/early.silt b/tests/golden/typecheck/modules/impl_place__m10_an_impl_that_reads_a_let_of_its_module/early.silt index 37fdd07f2..25b7c956d 100644 --- a/tests/golden/typecheck/modules/impl_place__m10_an_impl_that_reads_a_let_of_its_module/early.silt +++ b/tests/golden/typecheck/modules/impl_place__m10_an_impl_that_reads_a_let_of_its_module/early.silt @@ -1,11 +1,12 @@ import types.{ Tag } +import string pub fn show(x: a) -> String where a: Display { - x.display() + "{x}" } -pub let text = Tag { name: "e" }.display() +pub let text = string.from(Tag { name: "e" }) pub let text2 = show(Tag { name: "e2" }) -pub let text3 = Tag.display(Tag { name: "e3" }) +pub let text3 = string.from(Tag { name: "e3" }) diff --git a/tests/golden/typecheck/modules/impl_place__m10_an_impl_that_reads_a_let_of_its_module/main.silt b/tests/golden/typecheck/modules/impl_place__m10_an_impl_that_reads_a_let_of_its_module/main.silt index a761f58e7..adf1cd3cd 100644 --- a/tests/golden/typecheck/modules/impl_place__m10_an_impl_that_reads_a_let_of_its_module/main.silt +++ b/tests/golden/typecheck/modules/impl_place__m10_an_impl_that_reads_a_let_of_its_module/main.silt @@ -4,11 +4,12 @@ -- it is initialised first. import early import types.{ Tag } +import string fn main() { println(early.text) println(early.text2) println(early.text3) - println(Tag { name: "m" }.display()) + println(string.from(Tag { name: "m" })) println(early.show(Tag { name: "m2" })) } diff --git a/tests/golden/typecheck/modules/impl_place__m11_called_through_a_function_of_another_module/early.silt b/tests/golden/typecheck/modules/impl_place__m11_called_through_a_function_of_another_module/early.silt index 30aa72e60..29ecc9380 100644 --- a/tests/golden/typecheck/modules/impl_place__m11_called_through_a_function_of_another_module/early.silt +++ b/tests/golden/typecheck/modules/impl_place__m11_called_through_a_function_of_another_module/early.silt @@ -1,5 +1,6 @@ import types.{ Tag } +import string pub fn show3() -> String { - Tag.display(Tag { name: "e3" }) + string.from(Tag { name: "e3" }) } diff --git a/tests/golden/typecheck/modules/impl_place__the_error_names_both_modules/main.silt b/tests/golden/typecheck/modules/impl_place__the_error_names_both_modules/main.silt index 29aad99b4..362040e3c 100644 --- a/tests/golden/typecheck/modules/impl_place__the_error_names_both_modules/main.silt +++ b/tests/golden/typecheck/modules/impl_place__the_error_names_both_modules/main.silt @@ -1,7 +1,7 @@ -- cmd: check -- exit: 1 -- stderr-contains: the impl of trait 'traits.Area' for type 'shapes.Square' is written in module 'main', which declares neither the trait nor the type; it may be written in module 'traits', which declares the trait, or in module 'shapes', which declares the type --- stderr-contains: unknown field or method 'area' on type shapes.Square +-- stderr-contains: type 'shapes.Square' does not implement trait 'traits.Area' -- An impl written elsewhere is no impl: nothing is called through it. import shapes.{ Square } import traits.{ Area } @@ -13,5 +13,5 @@ trait Area for Square { } fn main() { - println(Square { side: 2 }.area()) + println(Area.area(Square { side: 2 })) } diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_of_a_module_imported_by_an_import/a.silt b/tests/golden/typecheck/modules/method_reach__a_trait_is_called_where_it_is_named/a.silt similarity index 100% rename from tests/golden/typecheck/modules/method_reach__a_trait_of_a_module_imported_by_an_import/a.silt rename to tests/golden/typecheck/modules/method_reach__a_trait_is_called_where_it_is_named/a.silt diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_of_a_module_imported_by_an_import/case.stdout b/tests/golden/typecheck/modules/method_reach__a_trait_is_called_where_it_is_named/case.stdout similarity index 100% rename from tests/golden/typecheck/modules/method_reach__a_trait_of_a_module_imported_by_an_import/case.stdout rename to tests/golden/typecheck/modules/method_reach__a_trait_is_called_where_it_is_named/case.stdout diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_is_called_where_it_is_named/m.silt b/tests/golden/typecheck/modules/method_reach__a_trait_is_called_where_it_is_named/m.silt new file mode 100644 index 000000000..7d63cf283 --- /dev/null +++ b/tests/golden/typecheck/modules/method_reach__a_trait_is_called_where_it_is_named/m.silt @@ -0,0 +1,5 @@ +import a + +pub fn both(x: t) -> String where t: a.Tag { + "{a.Tag.tag(x)} {a.Tag.tag(x)}" +} diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_is_called_where_it_is_named/main.silt b/tests/golden/typecheck/modules/method_reach__a_trait_is_called_where_it_is_named/main.silt new file mode 100644 index 000000000..dcc1e9750 --- /dev/null +++ b/tests/golden/typecheck/modules/method_reach__a_trait_is_called_where_it_is_named/main.silt @@ -0,0 +1,10 @@ +-- A trait's method is called where the trait is named: `m` names it +-- through its module, `a.Tag`; `main` imports it by name, though `m` +-- already imports its module. +import a.{ Tag } +import m + +fn main() { + println(Tag.tag(3)) + println(m.both(4)) +} diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_of_a_module_imported_by_an_import/m.silt b/tests/golden/typecheck/modules/method_reach__a_trait_of_a_module_imported_by_an_import/m.silt deleted file mode 100644 index 90cdf003b..000000000 --- a/tests/golden/typecheck/modules/method_reach__a_trait_of_a_module_imported_by_an_import/m.silt +++ /dev/null @@ -1,5 +0,0 @@ -import a - -pub fn both(x: a) -> String where a: a.Tag { - "{x.tag()} {x.tag()}" -} diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_of_a_module_imported_by_an_import/main.silt b/tests/golden/typecheck/modules/method_reach__a_trait_of_a_module_imported_by_an_import/main.silt deleted file mode 100644 index a9baccbca..000000000 --- a/tests/golden/typecheck/modules/method_reach__a_trait_of_a_module_imported_by_an_import/main.silt +++ /dev/null @@ -1,8 +0,0 @@ --- `main` imports `m`, which imports the trait's module: the trait's --- methods are called here without an import of its own. -import m - -fn main() { - println(3.tag()) - println(m.both(4)) -} diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_after/a.silt b/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_after/a.silt deleted file mode 100644 index fb4f94943..000000000 --- a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_after/a.silt +++ /dev/null @@ -1,16 +0,0 @@ -pub trait Tag { - fn tag(self) -> String - fn tagged(self) -> String { - "<{self.tag()}>" - } -} - -trait Tag for Int { - fn tag(self) -> String { - "int {self}" - } -} - -pub fn touch() -> Int { - 0 -} diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_after/c.silt b/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_after/c.silt deleted file mode 100644 index 71fbc1b5f..000000000 --- a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_after/c.silt +++ /dev/null @@ -1,3 +0,0 @@ -pub fn v() -> String { - 3.tagged() -} diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_after/main.silt b/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_after/main.silt deleted file mode 100644 index a8c144782..000000000 --- a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_after/main.silt +++ /dev/null @@ -1,17 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown method 'tagged' on type Int --- stderr-contains: trait 'Tag' of module 'a' has a method 'tagged' for this type; import 'a' to call it --- A module calls the methods of the traits whose modules it imports --- (or they import, and so on). `c` does not import `a`: whether `a` --- was checked before `c` or after it, `c` has no method `tagged`. --- (It once had it when an earlier import had brought the impl in.) The --- help that names the module is made once all modules are checked: it --- is there in both orders. -import c -import a - -fn main() { - println(c.v()) - println(a.touch()) -} diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_before/a.silt b/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_before/a.silt deleted file mode 100644 index fb4f94943..000000000 --- a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_before/a.silt +++ /dev/null @@ -1,16 +0,0 @@ -pub trait Tag { - fn tag(self) -> String - fn tagged(self) -> String { - "<{self.tag()}>" - } -} - -trait Tag for Int { - fn tag(self) -> String { - "int {self}" - } -} - -pub fn touch() -> Int { - 0 -} diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_before/c.silt b/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_before/c.silt deleted file mode 100644 index 71fbc1b5f..000000000 --- a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_before/c.silt +++ /dev/null @@ -1,3 +0,0 @@ -pub fn v() -> String { - 3.tagged() -} diff --git a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_before/main.silt b/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_before/main.silt deleted file mode 100644 index 37b761782..000000000 --- a/tests/golden/typecheck/modules/method_reach__a_trait_out_of_reach__imported_before/main.silt +++ /dev/null @@ -1,15 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown method 'tagged' on type Int --- stderr-contains: trait 'Tag' of module 'a' has a method 'tagged' for this type; import 'a' to call it --- A module calls the methods of the traits whose modules it imports --- (or they import, and so on). `c` does not import `a`: whether `a` --- was checked before `c` or after it, `c` has no method `tagged`. --- (It once had it when an earlier import had brought the impl in.) -import a -import c - -fn main() { - println(c.v()) - println(a.touch()) -} diff --git a/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/c.silt b/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/c.silt deleted file mode 100644 index 9315c57a7..000000000 --- a/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/c.silt +++ /dev/null @@ -1,9 +0,0 @@ -import shapes - -pub fn on_a_value() -> Int { - shapes.Square { side: 2 }.area() -} - -pub fn through_the_type() -> Int { - shapes.Square.area(shapes.Square { side: 3 }) -} diff --git a/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/main.silt b/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/main.silt deleted file mode 100644 index 98436383a..000000000 --- a/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/main.silt +++ /dev/null @@ -1,14 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: unknown field or method 'area' on type shapes.Square --- stderr-contains: type 'shapes.Square' has no method 'area' --- stderr-contains: trait 'Area' of module 'traits' has a method 'area' for this type; import 'traits' to call it --- The help names the module to import for a method called on a value --- of a declared type and through the type, with the trait's module --- checked after the caller. -import c -import traits - -fn main() { - println(c.on_a_value() + c.through_the_type() + traits.touch()) -} diff --git a/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/shapes.silt b/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/shapes.silt deleted file mode 100644 index 736894780..000000000 --- a/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/shapes.silt +++ /dev/null @@ -1,3 +0,0 @@ -pub type Square { - side: Int, -} diff --git a/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/traits.silt b/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/traits.silt deleted file mode 100644 index 438d78276..000000000 --- a/tests/golden/typecheck/modules/method_reach__the_help_for_a_type_of_a_module/traits.silt +++ /dev/null @@ -1,15 +0,0 @@ -import shapes - -pub trait Area { - fn area(self) -> Int -} - -trait Area for shapes.Square { - fn area(self) -> Int { - self.side * self.side - } -} - -pub fn touch() -> Int { - 0 -} diff --git a/tests/golden/typecheck/modules/method_reach__the_trait_is_in_a_module_that_imports_this_one/c.silt b/tests/golden/typecheck/modules/method_reach__the_trait_is_in_a_module_that_imports_this_one/c.silt deleted file mode 100644 index 032730bc9..000000000 --- a/tests/golden/typecheck/modules/method_reach__the_trait_is_in_a_module_that_imports_this_one/c.silt +++ /dev/null @@ -1,5 +0,0 @@ -import shapes - -pub fn on_a_value() -> Int { - shapes.Square { side: 2 }.area() -} diff --git a/tests/golden/typecheck/modules/method_reach__the_trait_is_in_a_module_that_imports_this_one/main.silt b/tests/golden/typecheck/modules/method_reach__the_trait_is_in_a_module_that_imports_this_one/main.silt deleted file mode 100644 index 1e10a6027..000000000 --- a/tests/golden/typecheck/modules/method_reach__the_trait_is_in_a_module_that_imports_this_one/main.silt +++ /dev/null @@ -1,26 +0,0 @@ --- cmd: check --- exit: 1 --- verdict: same --- stderr-contains: c.silt:4:3 --- stderr-contains: unknown field or method 'area' on type shapes.Square --- stderr-contains: trait 'Area' of module 'main' has a method 'area' for this type, but 'main' imports this module and cannot be imported by it --- stderr-not-contains: import 'main' to call it --- The trait that has the method is declared in a module that imports --- the one that calls it: importing it there would be a cycle, so the --- help does not say to. It says where the trait would have to be. -import c -import shapes - -pub trait Area { - fn area(self) -> Int -} - -trait Area for shapes.Square { - fn area(self) -> Int { - self.side * self.side - } -} - -fn main() { - println(c.on_a_value()) -} diff --git a/tests/golden/typecheck/modules/method_reach__the_trait_is_in_a_module_that_imports_this_one/shapes.silt b/tests/golden/typecheck/modules/method_reach__the_trait_is_in_a_module_that_imports_this_one/shapes.silt deleted file mode 100644 index 736894780..000000000 --- a/tests/golden/typecheck/modules/method_reach__the_trait_is_in_a_module_that_imports_this_one/shapes.silt +++ /dev/null @@ -1,3 +0,0 @@ -pub type Square { - side: Int, -} diff --git a/tests/golden/typecheck/operators/compare__tuple_holding_a_function.silt b/tests/golden/typecheck/operators/compare__tuple_holding_a_function.silt index 14b16f39e..31488fbe6 100644 --- a/tests/golden/typecheck/operators/compare__tuple_holding_a_function.silt +++ b/tests/golden/typecheck/operators/compare__tuple_holding_a_function.silt @@ -10,5 +10,5 @@ fn main() { println((1, f) < (1, f)) println(lt((1, f), (2, f))) println(list.sort([(1, #{ "a": 1 })])) - println((1, #[1]).compare((1, #[2]))) + println(Compare.compare((1, #[1]), (1, #[2]))) } diff --git a/tests/golden/typecheck/operators/compare__tuples_bool_and_unit_are_ordered.silt b/tests/golden/typecheck/operators/compare__tuples_bool_and_unit_are_ordered.silt index 750d0702b..a9e92c33d 100644 --- a/tests/golden/typecheck/operators/compare__tuples_bool_and_unit_are_ordered.silt +++ b/tests/golden/typecheck/operators/compare__tuples_bool_and_unit_are_ordered.silt @@ -4,16 +4,16 @@ import list type Pair { t: (Int, Int) } fn lt(x: a, y: a) -> Bool where a: Compare { x < y } -fn cmp(x: a, y: a) -> Int where a: Compare { x.compare(y) } +fn cmp(x: a, y: a) -> Int where a: Compare { Compare.compare(x, y) } fn less(x, y) { x <= y } fn main() { println((1, "a") < (1, "b")) println((2, 1) >= (1, 9)) - println((1, 2).compare((1, 3))) + println(Compare.compare((1, 2), (1, 3))) println(false < true) - println(true.compare(false)) + println(Compare.compare(true, false)) println(() <= ()) - println(().compare(())) + println(Compare.compare((), ())) println(lt((1, true), (1, false))) println(cmp((1, (2, "x")), (1, (2, "x")))) println(lt(false, true)) diff --git a/tests/golden/typecheck/operators/type_domain__field_access_on_int.silt b/tests/golden/typecheck/operators/type_domain__field_access_on_int.silt index 07c71c88e..25a9a4881 100644 --- a/tests/golden/typecheck/operators/type_domain__field_access_on_int.silt +++ b/tests/golden/typecheck/operators/type_domain__field_access_on_int.silt @@ -1,6 +1,6 @@ -- cmd: check -- exit: 1 --- stderr-contains: unknown method 'foo' +-- stderr-contains: type 'Int' has no field 'foo' fn main() { let x = 42 let _ = x.foo diff --git a/tests/golden/typecheck/operators/type_domain__record_wrong_field.silt b/tests/golden/typecheck/operators/type_domain__record_wrong_field.silt index 905e67747..f14db7fdb 100644 --- a/tests/golden/typecheck/operators/type_domain__record_wrong_field.silt +++ b/tests/golden/typecheck/operators/type_domain__record_wrong_field.silt @@ -1,6 +1,6 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: unknown field or method 'z' on type Point +-- stderr-contains: error[type]: type 'Point' has no field 'z' type Point { x: Int, y: Int } fn main() { let p = Point { x: 1, y: 2 } diff --git a/tests/golden/typecheck/ranges/round92_range_hash__equal_over_cap_ranges_hash_equal.silt b/tests/golden/typecheck/ranges/round92_range_hash__equal_over_cap_ranges_hash_equal.silt index f9285c970..9a0023994 100644 --- a/tests/golden/typecheck/ranges/round92_range_hash__equal_over_cap_ranges_hash_equal.silt +++ b/tests/golden/typecheck/ranges/round92_range_hash__equal_over_cap_ranges_hash_equal.silt @@ -3,5 +3,5 @@ fn main() { let a = 0..4000000000 let b = 0..4000000000 println(a == b) - println(a.hash() == b.hash()) + println(Hash.hash(a) == Hash.hash(b)) } diff --git a/tests/golden/typecheck/ranges/round92_range_hash__huge_range_hash_completes.silt b/tests/golden/typecheck/ranges/round92_range_hash__huge_range_hash_completes.silt index 90a2bc93c..1baa2600b 100644 --- a/tests/golden/typecheck/ranges/round92_range_hash__huge_range_hash_completes.silt +++ b/tests/golden/typecheck/ranges/round92_range_hash__huge_range_hash_completes.silt @@ -1,10 +1,10 @@ -- Hashing a ~4e9-element range (and one near i64::MAX) is closed-form and finishes promptly. fn main() { let r = 0..4000000000 - let h = r.hash() + let h = Hash.hash(r) println("hashed ok") let big = 0..9223372036854775806 - let h2 = big.hash() + let h2 = Hash.hash(big) println("hashed max ok") println(h == h) println(h2 == h2) diff --git a/tests/golden/typecheck/ranges/round92_range_hash__nested_huge_range_hash_completes.silt b/tests/golden/typecheck/ranges/round92_range_hash__nested_huge_range_hash_completes.silt index fadb87dbb..17dcf3362 100644 --- a/tests/golden/typecheck/ranges/round92_range_hash__nested_huge_range_hash_completes.silt +++ b/tests/golden/typecheck/ranges/round92_range_hash__nested_huge_range_hash_completes.silt @@ -2,10 +2,10 @@ type R { xs: List(Int) } fn main() { let t = (1, 0..4000000000) - let th = t.hash() + let th = Hash.hash(t) println("tuple hashed ok") let r = R { xs: 0..4000000000 } - let rh = r.hash() + let rh = Hash.hash(r) println("record hashed ok") println(th == th) println(rh == rh) diff --git a/tests/golden/typecheck/ranges/round92_range_hash__small_range_list_hash_contract.silt b/tests/golden/typecheck/ranges/round92_range_hash__small_range_list_hash_contract.silt index b19a9edf0..14d4204ed 100644 --- a/tests/golden/typecheck/ranges/round92_range_hash__small_range_list_hash_contract.silt +++ b/tests/golden/typecheck/ranges/round92_range_hash__small_range_list_hash_contract.silt @@ -1,4 +1,4 @@ -- Within the cap, a range hashes equal to the equal list. fn main() { - println((1..5).hash() == [1, 2, 3, 4, 5].hash()) + println(Hash.hash(1..5) == Hash.hash([1, 2, 3, 4, 5])) } diff --git a/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_const_on_range.silt b/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_const_on_range.silt index afc98a39f..a72406141 100644 --- a/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_const_on_range.silt +++ b/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_const_on_range.silt @@ -2,5 +2,5 @@ trait Foo { fn bar(self) -> Int } trait Foo for List(a) { fn bar(self) -> Int { 42 } } fn main() { let r = 1..5 - println(r.bar()) + println(Foo.bar(r)) } diff --git a/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_on_range_literal.silt b/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_on_range_literal.silt index ffa7c721d..0f7f732eb 100644 --- a/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_on_range_literal.silt +++ b/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_on_range_literal.silt @@ -3,5 +3,5 @@ trait Sum { fn sum_of(self) -> Int } type Ints = List(Int) trait Sum for Ints { fn sum_of(self) -> Int { list.sum(self) } } fn main() { - println((2..4).sum_of()) + println(Sum.sum_of(2..4)) } diff --git a/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_uses_self_on_range.silt b/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_uses_self_on_range.silt index 09173be13..cbb2a66f5 100644 --- a/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_uses_self_on_range.silt +++ b/tests/golden/typecheck/ranges/vm_range_receiver_trait_method__list_impl_uses_self_on_range.silt @@ -4,5 +4,5 @@ type Ints = List(Int) trait Sum for Ints { fn sum_of(self) -> Int { list.sum(self) } } fn main() { let r = 1..5 - println(r.sum_of()) + println(Sum.sum_of(r)) } diff --git a/tests/golden/typecheck/records/inference_round26__field_access_no_near_match.silt b/tests/golden/typecheck/records/inference_round26__field_access_no_near_match.silt index a026a74a7..1103500cb 100644 --- a/tests/golden/typecheck/records/inference_round26__field_access_no_near_match.silt +++ b/tests/golden/typecheck/records/inference_round26__field_access_no_near_match.silt @@ -1,6 +1,6 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: unknown field or method 'completelydifferent' on type User +-- stderr-contains: error[type]: type 'User' has no field 'completelydifferent' -- stderr-not-contains: did you mean type User { name: String, age: Int } fn main() { diff --git a/tests/golden/typecheck/records/inference_round26__field_access_typo_suggests.silt b/tests/golden/typecheck/records/inference_round26__field_access_typo_suggests.silt index 2a4f94f63..a0f9a4451 100644 --- a/tests/golden/typecheck/records/inference_round26__field_access_typo_suggests.silt +++ b/tests/golden/typecheck/records/inference_round26__field_access_typo_suggests.silt @@ -1,6 +1,6 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: unknown field or method 'nam' on type User +-- stderr-contains: error[type]: type 'User' has no field 'nam' -- stderr-contains: did you mean `name`? type User { name: String, age: Int } fn main() { diff --git a/tests/golden/typecheck/records/nominal__open_row_needs_its_listed_fields.silt b/tests/golden/typecheck/records/nominal__open_row_needs_its_listed_fields.silt index 3ec0816b2..9ae462118 100644 --- a/tests/golden/typecheck/records/nominal__open_row_needs_its_listed_fields.silt +++ b/tests/golden/typecheck/records/nominal__open_row_needs_its_listed_fields.silt @@ -1,6 +1,6 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: record Person has no field 'email' +-- stderr-contains: error[type]: type 'Person' has no field 'email' -- stderr-contains: error[type]: type mismatch: expected String, got Int type Person { name: String, age: Int } fn email_of(p: {email: String, ...r}) -> String { p.email } diff --git a/tests/golden/typecheck/records/nominal__through_an_open_row_stays_itself.silt b/tests/golden/typecheck/records/nominal__through_an_open_row_stays_itself.silt index be9003a0a..113e37061 100644 --- a/tests/golden/typecheck/records/nominal__through_an_open_row_stays_itself.silt +++ b/tests/golden/typecheck/records/nominal__through_an_open_row_stays_itself.silt @@ -10,7 +10,7 @@ fn older(p: Person) -> Person { p.{ age: p.age + 1 } } fn main() { let q = id_name(Person { name: "Bob", age: 42 }) println(q.age) - println(q.greet()) + println(Greet.greet(q)) println(older(q).age) println(name_of(q)) match q { Person { name, age } -> println("{name} {age}") } diff --git a/tests/golden/typecheck/records/round73_typechecker_fixes__anon_record_no_user_trait_bypass.silt b/tests/golden/typecheck/records/round73_typechecker_fixes__anon_record_no_user_trait_bypass.silt index e33e8a8ba..060d8aa31 100644 --- a/tests/golden/typecheck/records/round73_typechecker_fixes__anon_record_no_user_trait_bypass.silt +++ b/tests/golden/typecheck/records/round73_typechecker_fixes__anon_record_no_user_trait_bypass.silt @@ -7,7 +7,7 @@ trait MyTrait { trait MyTrait for Int { fn my_ident(self) -> Int { self } } -fn use_it(x: a) -> Int where a: MyTrait { x.my_ident() } +fn use_it(x: a) -> Int where a: MyTrait { MyTrait.my_ident(x) } fn main() { let r = {x: 1, y: 2} let _ = use_it(r) diff --git a/tests/golden/typecheck/records/round81_anon_record_typeck_fixes__field_access_typo_hint.silt b/tests/golden/typecheck/records/round81_anon_record_typeck_fixes__field_access_typo_hint.silt index 47d4f3a5e..7466c6ab7 100644 --- a/tests/golden/typecheck/records/round81_anon_record_typeck_fixes__field_access_typo_hint.silt +++ b/tests/golden/typecheck/records/round81_anon_record_typeck_fixes__field_access_typo_hint.silt @@ -1,7 +1,7 @@ -- cmd: check -- exit: 1 --- A typo'd field on an anonymous record keeps its wording and gains a did-you-mean hint. --- stderr-contains: anon record has no field 'nam' +-- A typo'd field on an anonymous record is named by its type and gains a did-you-mean hint. +-- stderr-contains: type '{name: String}' has no field 'nam' -- stderr-contains: did you mean `name`? fn main() { let r = {name: "x"} diff --git a/tests/golden/typecheck/records/rows__a_method_is_not_a_field_of_the_row.silt b/tests/golden/typecheck/records/rows__a_method_is_not_a_field_of_the_row.silt index da1b708b1..9a0ddd1bb 100644 --- a/tests/golden/typecheck/records/rows__a_method_is_not_a_field_of_the_row.silt +++ b/tests/golden/typecheck/records/rows__a_method_is_not_a_field_of_the_row.silt @@ -1,12 +1,11 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: record Person has no field 'greet' --- stderr-contains: help: 'greet' is a method of `Person`, and what is asked for here is a record with a field 'greet' --- stderr-contains: annotate it, `p: Person` --- stderr-contains: 18:17 +-- stderr-contains: error[type]: type 'Person' has no field 'greet' +-- stderr-contains: help: `greet` is a method of trait `Greet`: call it as `Greet.greet(x)` +-- stderr-contains: 17:17 -- A value whose field is read is a record, and `p.greet()` on it calls --- a function its field `greet` holds: a `Person` has a method of that --- name, not a field, and the error says so. +-- a function its field `greet` holds: a `Person` has no such field, and +-- the help names the trait whose method `greet` is. type Person { name: String, age: Int } trait Greet { fn greet(self) -> String } trait Greet for Person { fn greet(self) -> String { "I am {self.name}" } } diff --git a/tests/golden/typecheck/records/rows__an_anonymous_record_has_no_written_impl.silt b/tests/golden/typecheck/records/rows__an_anonymous_record_has_no_written_impl.silt index 41fd1f5a2..8be9ee4b5 100644 --- a/tests/golden/typecheck/records/rows__an_anonymous_record_has_no_written_impl.silt +++ b/tests/golden/typecheck/records/rows__an_anonymous_record_has_no_written_impl.silt @@ -7,8 +7,8 @@ -- A message writes an anonymous record's type, not a name for it. trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "i" } } -fn f(x) { x.greet() } -fn g(x: a) -> String where a: Greet { x.greet() } +fn f(x) { Greet.greet(x) } +fn g(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { println(f({name: "a"})) println(g({name: "a"})) diff --git a/tests/golden/typecheck/records/rows__annotation_row_is_rigid.silt b/tests/golden/typecheck/records/rows__annotation_row_is_rigid.silt index 227eaeece..65717b6c6 100644 --- a/tests/golden/typecheck/records/rows__annotation_row_is_rigid.silt +++ b/tests/golden/typecheck/records/rows__annotation_row_is_rigid.silt @@ -1,6 +1,6 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: anon record has no field 'age' +-- stderr-contains: error[type]: type '{name: String, ...r}' has no field 'age' -- stderr-contains: error[type]: type mismatch: expected {name: String, ...r}, got {name: String} -- The row variable of an annotation is whatever the caller's record -- has: the function may not read a field behind it, nor return a diff --git a/tests/golden/typecheck/records/rows__spread_over_a_row_no_signature_owns.silt b/tests/golden/typecheck/records/rows__spread_over_a_row_no_signature_owns.silt index 0cb50fd75..dd10e4544 100644 --- a/tests/golden/typecheck/records/rows__spread_over_a_row_no_signature_owns.silt +++ b/tests/golden/typecheck/records/rows__spread_over_a_row_no_signature_owns.silt @@ -12,5 +12,5 @@ trait Tag { fn tag(self, p: {name: String, ...r}) -> {name: String, ...r} } trait Tag for Int { fn tag(self, p: {name: String, ...r}) -> {name: String, ...r} { {...p} } } fn main() { let f: Fn({name: String, ...r}) -> {name: String, ...r} = { p -> {...p} } - println(1.tag(Person { name: "a", age: 1 })) + println(Tag.tag(1, Person { name: "a", age: 1 })) } diff --git a/tests/golden/typecheck/records/rows__trait_method_row_accepts.silt b/tests/golden/typecheck/records/rows__trait_method_row_accepts.silt index 784ac67ca..b13fd1fb9 100644 --- a/tests/golden/typecheck/records/rows__trait_method_row_accepts.silt +++ b/tests/golden/typecheck/records/rows__trait_method_row_accepts.silt @@ -6,7 +6,7 @@ trait Keep { fn keep(self, p: {name: String, ...r}) -> {name: String, ...r} { p trait Keep for Int {} type Person { name: String, age: Int } fn main() { - println(1.name_of({name: "a", age: 1})) - println(1.keep(Person { name: "b", age: 2 }).age) - println(1.keep({name: "c", z: true}).z) + println(Namer.name_of(1, {name: "a", age: 1})) + println(Keep.keep(1, Person { name: "b", age: 2 }).age) + println(Keep.keep(1, {name: "c", z: true}).z) } diff --git a/tests/golden/typecheck/records/rows__trait_method_row_is_rigid.silt b/tests/golden/typecheck/records/rows__trait_method_row_is_rigid.silt index 19a2fffba..5969692a1 100644 --- a/tests/golden/typecheck/records/rows__trait_method_row_is_rigid.silt +++ b/tests/golden/typecheck/records/rows__trait_method_row_is_rigid.silt @@ -1,10 +1,10 @@ -- cmd: check -- exit: 1 --- stderr-contains: error[type]: anon record has no field 'age' +-- stderr-contains: error[type]: type '{name: String, ...r}' has no field 'age' -- stderr-contains: error[type]: type mismatch: expected {name: String, ...r}, got {name: String} -- The row variable of a trait method's or an impl method's annotation -- is fixed inside the body, as in a function's signature. trait Namer { fn name_of(self, p: {name: String, ...r}) -> String } trait Namer for Bool { fn name_of(self, p: {name: String, ...r}) -> String { "{p.name} {p.age}" } } trait Bad { fn bad(self, p: {name: String, ...r}) -> {name: String, ...r} { {name: "x"} } } -fn main() { println(true.name_of({name: "a", age: 1})) } +fn main() { println(Namer.name_of(true, {name: "a", age: 1})) } diff --git a/tests/golden/typecheck/traits/default_method__body_checked_without_impl_using_it.silt b/tests/golden/typecheck/traits/default_method__body_checked_without_impl_using_it.silt index b2b51ce08..0e3f71956 100644 --- a/tests/golden/typecheck/traits/default_method__body_checked_without_impl_using_it.silt +++ b/tests/golden/typecheck/traits/default_method__body_checked_without_impl_using_it.silt @@ -9,4 +9,4 @@ trait Area { } type Sq { side: Float } trait Area for Sq { fn area(self) -> Float { self.side * self.side } } -fn main() { println(Sq { side: 2.0 }.area()) } +fn main() { println(Area.area(Sq { side: 2.0 })) } diff --git a/tests/golden/typecheck/traits/default_method__calls_trait_and_supertrait_methods.silt b/tests/golden/typecheck/traits/default_method__calls_trait_and_supertrait_methods.silt index 0dda968ed..d53c3a3ba 100644 --- a/tests/golden/typecheck/traits/default_method__calls_trait_and_supertrait_methods.silt +++ b/tests/golden/typecheck/traits/default_method__calls_trait_and_supertrait_methods.silt @@ -3,9 +3,9 @@ trait Named { fn name(self) -> String } trait Loud: Named { fn volume(self) -> Int - fn shout(self) -> String { "{self.name()}{self.bangs()}" } + fn shout(self) -> String { "{Named.name(self)}{Loud.bangs(self)}" } fn bangs(self) -> String { - match self.volume() > 1 { + match Loud.volume(self) > 1 { true -> "!!" false -> "!" } @@ -21,6 +21,6 @@ trait Loud for Cat { fn bangs(self) -> String { "?" } } fn main() { - println(Dog { n: "rex" }.shout()) - println(Cat { n: "tom" }.shout()) + println(Loud.shout(Dog { n: "rex" })) + println(Loud.shout(Cat { n: "tom" })) } diff --git a/tests/golden/typecheck/traits/default_method__uses_unpromised_field.silt b/tests/golden/typecheck/traits/default_method__uses_unpromised_field.silt index 3eae69edd..f2a2b03ba 100644 --- a/tests/golden/typecheck/traits/default_method__uses_unpromised_field.silt +++ b/tests/golden/typecheck/traits/default_method__uses_unpromised_field.silt @@ -3,7 +3,7 @@ -- A default method is checked once, in its trait: `Self` has what the -- trait and its supertraits promise, not the fields of the types that -- happen to implement it. --- stderr-contains: no method 'label' found in trait constraints (Loud) +-- stderr-contains: type 'Self' has no field 'label' -- stderr-contains: default_method__uses_unpromised_field.silt:10:32 trait Loud { fn volume(self) -> Int @@ -11,4 +11,4 @@ trait Loud { } type Dog { label: String } trait Loud for Dog { fn volume(self) -> Int { 2 } } -fn main() { println(Dog { label: "rex" }.shout()) } +fn main() { println(Loud.shout(Dog { label: "rex" })) } diff --git a/tests/golden/typecheck/traits/field_method__default_method.silt b/tests/golden/typecheck/traits/field_method__default_method.silt index 4aa71a3f6..de8bae59e 100644 --- a/tests/golden/typecheck/traits/field_method__default_method.silt +++ b/tests/golden/typecheck/traits/field_method__default_method.silt @@ -17,5 +17,5 @@ trait Run for H { fn main() { let h = H { run: 1, name: "n" } println(h.run) - println(h.stop()) + println(Run.stop(h)) } diff --git a/tests/golden/typecheck/traits/field_method__impl_in_the_traits_module/runner.silt b/tests/golden/typecheck/traits/field_method__impl_in_the_traits_module/runner.silt index 8cd921dfb..d5203391a 100644 --- a/tests/golden/typecheck/traits/field_method__impl_in_the_traits_module/runner.silt +++ b/tests/golden/typecheck/traits/field_method__impl_in_the_traits_module/runner.silt @@ -2,4 +2,4 @@ import shapes pub trait Run { fn run(self, x: Int) -> Int } trait Run for shapes.H { fn run(self, x: Int) -> Int { x + self.n } } trait Run for Int { fn run(self, x: Int) -> Int { self + x } } -pub fn go(x: Int) -> Int { x.run(1) } +pub fn go(x: Int) -> Int { Run.run(x, 1) } diff --git a/tests/golden/typecheck/traits/field_method__supertrait_default_method.silt b/tests/golden/typecheck/traits/field_method__supertrait_default_method.silt index 1a7f5c84a..986fe672b 100644 --- a/tests/golden/typecheck/traits/field_method__supertrait_default_method.silt +++ b/tests/golden/typecheck/traits/field_method__supertrait_default_method.silt @@ -9,5 +9,5 @@ type H { size: Int } trait Base for H {} trait Top for H { fn top(self) -> Int { self.size } } fn main() { - println(H { size: 2 }.top()) + println(Top.top(H { size: 2 })) } diff --git a/tests/golden/typecheck/traits/field_method__what_is_no_clash.silt b/tests/golden/typecheck/traits/field_method__what_is_no_clash.silt index aed0738ba..8635c5c17 100644 --- a/tests/golden/typecheck/traits/field_method__what_is_no_clash.silt +++ b/tests/golden/typecheck/traits/field_method__what_is_no_clash.silt @@ -23,18 +23,18 @@ type H { run: Fn(Int) -> Int, area: Int } type Other { n: Int } trait Run for Other { fn run(self, x: Int) -> Int { self.n * x } } fn run(x: Int) -> Int { x * 2 } -fn bounded(r: a, x: Int) -> Int where a: Run { r.run(x) } -fn inferred(r, x) { r.run(x) } +fn bounded(r: a, x: Int) -> Int where a: Run { Run.run(r, x) } +fn inferred(r, x) { Run.run(r, x) } fn main() { let h = H { run: { x -> x + 1 }, area: 9 } println(h.run(1)) println(1 |> h.run) println(h.area) - println(3.run(4)) - println(Other { n: 5 }.run(2)) + println(Run.run(3, 4)) + println(Run.run(Other { n: 5 }, 2)) println(bounded(Other { n: 5 }, 3)) println(run(5)) - println(Circle(2).area()) + println(Area.area(Circle(2))) let anon = {run: { x -> x - 1 }} println(anon.run(0)) let hs = [h, H { run: { x -> x * 10 }, area: 0 }] diff --git a/tests/golden/typecheck/traits/field_method__written_method.silt b/tests/golden/typecheck/traits/field_method__written_method.silt index d3e6e911a..c7f559574 100644 --- a/tests/golden/typecheck/traits/field_method__written_method.silt +++ b/tests/golden/typecheck/traits/field_method__written_method.silt @@ -8,13 +8,13 @@ type H { run: Fn(Int) -> Int, n: Int } trait Run { fn run(self, x: Int) -> Int } trait Run for H { fn run(self, x: Int) -> Int { -1 } } -fn bounded(r: a, x: Int) -> Int where a: Run { r.run(x) } -fn inferred(r, x) { r.run(x) } +fn bounded(r: a, x: Int) -> Int where a: Run { Run.run(r, x) } +fn inferred(r, x) { Run.run(r, x) } fn main() { let h = H { run: { x -> x + 1 }, n: 0 } println(h.run(1)) println(bounded(h, 1)) println(inferred(h, 1)) - let k = { r -> r.run(2) } + let k = { r -> Run.run(r, 2) } println(k(h)) } diff --git a/tests/golden/typecheck/traits/impl_method_bound__restates_a_supertrait.silt b/tests/golden/typecheck/traits/impl_method_bound__restates_a_supertrait.silt index 295a16515..c3eda160f 100644 --- a/tests/golden/typecheck/traits/impl_method_bound__restates_a_supertrait.silt +++ b/tests/golden/typecheck/traits/impl_method_bound__restates_a_supertrait.silt @@ -5,9 +5,9 @@ trait Two: Greet { fn two(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Two for Int { fn two(self) -> String { "2" } } trait Sh { fn sh(self, x: a) -> String where a: Two } -trait Sh for Bool { fn sh(self, x: a) -> String where a: Greet { x.greet() } } -trait Sh for Int { fn sh(self, x: a) -> String { "{x.greet()}{x.two()}" } } +trait Sh for Bool { fn sh(self, x: a) -> String where a: Greet { Greet.greet(x) } } +trait Sh for Int { fn sh(self, x: a) -> String { "{Greet.greet(x)}{Two.two(x)}" } } fn main() { - println(true.sh(1)) - println(1.sh(1)) + println(Sh.sh(true, 1)) + println(Sh.sh(1, 1)) } diff --git a/tests/golden/typecheck/traits/impl_method_bound__trait_argument_differs.silt b/tests/golden/typecheck/traits/impl_method_bound__trait_argument_differs.silt index 2d877d65d..64f8e49f1 100644 --- a/tests/golden/typecheck/traits/impl_method_bound__trait_argument_differs.silt +++ b/tests/golden/typecheck/traits/impl_method_bound__trait_argument_differs.silt @@ -8,5 +8,5 @@ trait Conv(to) { fn conv(self) -> to } trait Conv(String) for Int { fn conv(self) -> String { "i" } } trait Conv(Int) for Bool { fn conv(self) -> Int { 1 } } trait Sh { fn sh(self, x: a) -> String where a: Conv(String) } -trait Sh for Int { fn sh(self, x: a) -> String where a: Conv(Int) { "{x.conv()}" } } -fn main() { println(1.sh(1)) } +trait Sh for Int { fn sh(self, x: a) -> String where a: Conv(Int) { "{Conv.conv(x)}" } } +fn main() { println(Sh.sh(1, 1)) } diff --git a/tests/golden/typecheck/traits/impl_method_bound__trait_argument_differs.stderr b/tests/golden/typecheck/traits/impl_method_bound__trait_argument_differs.stderr index 136e362bf..90cead629 100644 --- a/tests/golden/typecheck/traits/impl_method_bound__trait_argument_differs.stderr +++ b/tests/golden/typecheck/traits/impl_method_bound__trait_argument_differs.stderr @@ -1,6 +1,6 @@ error[type]: method 'sh' of the impl of 'Sh' for 'Int' adds the bound `a: Conv(Int)`, which the trait does not declare for it --> impl_method_bound__trait_argument_differs.silt:11:20 | - 11 | trait Sh for Int { fn sh(self, x: a) -> String where a: Conv(Int) { "{x.conv()}" } } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method 'sh' of the impl of 'Sh' for 'Int' adds the bound `a: Conv(Int)`, which the trait does not declare for it + 11 | trait Sh for Int { fn sh(self, x: a) -> String where a: Conv(Int) { "{Conv.conv(x)}" } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method 'sh' of the impl of 'Sh' for 'Int' adds the bound `a: Conv(Int)`, which the trait does not declare for it = help: a call through the trait would not owe it: declare the bound on the method in trait 'Sh', or on the impl's header diff --git a/tests/golden/typecheck/traits/multi_trait_bound__comma_form_accepts_both.silt b/tests/golden/typecheck/traits/multi_trait_bound__comma_form_accepts_both.silt index b744de3a8..e4c88f996 100644 --- a/tests/golden/typecheck/traits/multi_trait_bound__comma_form_accepts_both.silt +++ b/tests/golden/typecheck/traits/multi_trait_bound__comma_form_accepts_both.silt @@ -13,9 +13,9 @@ trait MyOrd for Int { } } fn use_both(x: a, y: a) -> Int where a: MyEq, a: MyOrd { - match x.my_eq(y) { + match MyEq.my_eq(x, y) { true -> 0 - false -> x.my_cmp(y) + false -> MyOrd.my_cmp(x, y) } } fn main() { println(use_both(5, 5)) } diff --git a/tests/golden/typecheck/traits/multi_trait_bound__comma_form_rejects_only_one.silt b/tests/golden/typecheck/traits/multi_trait_bound__comma_form_rejects_only_one.silt index e6cc215e0..752db1fa0 100644 --- a/tests/golden/typecheck/traits/multi_trait_bound__comma_form_rejects_only_one.silt +++ b/tests/golden/typecheck/traits/multi_trait_bound__comma_form_rejects_only_one.silt @@ -5,9 +5,9 @@ trait MyEq { fn my_eq(self, other: Self) -> Bool } trait MyOrd { fn my_cmp(self, other: Self) -> Int } trait MyEq for String { fn my_eq(self, other: String) -> Bool { self == other } } fn use_both(x: a, y: a) -> Int where a: MyEq, a: MyOrd { - match x.my_eq(y) { + match MyEq.my_eq(x, y) { true -> 0 - false -> x.my_cmp(y) + false -> MyOrd.my_cmp(x, y) } } fn main() { println(use_both("a", "b")) } diff --git a/tests/golden/typecheck/traits/multi_trait_bound__plus_form_accepts_both.silt b/tests/golden/typecheck/traits/multi_trait_bound__plus_form_accepts_both.silt index 4ba2feea5..f76d17781 100644 --- a/tests/golden/typecheck/traits/multi_trait_bound__plus_form_accepts_both.silt +++ b/tests/golden/typecheck/traits/multi_trait_bound__plus_form_accepts_both.silt @@ -13,9 +13,9 @@ trait MyOrd for Int { } } fn use_both(x: a, y: a) -> Int where a: MyEq + MyOrd { - match x.my_eq(y) { + match MyEq.my_eq(x, y) { true -> 0 - false -> x.my_cmp(y) + false -> MyOrd.my_cmp(x, y) } } fn main() { println(use_both(3, 7)) } diff --git a/tests/golden/typecheck/traits/multi_trait_bound__plus_form_rejects_first_missing.silt b/tests/golden/typecheck/traits/multi_trait_bound__plus_form_rejects_first_missing.silt index 3b3bb6b7c..0664a2938 100644 --- a/tests/golden/typecheck/traits/multi_trait_bound__plus_form_rejects_first_missing.silt +++ b/tests/golden/typecheck/traits/multi_trait_bound__plus_form_rejects_first_missing.silt @@ -15,9 +15,9 @@ trait MyOrd for Float { } } fn use_both(x: a, y: a) -> Int where a: MyEq + MyOrd { - match x.my_eq(y) { + match MyEq.my_eq(x, y) { true -> 0 - false -> x.my_cmp(y) + false -> MyOrd.my_cmp(x, y) } } fn main() { println(use_both(1.0, 2.0)) } diff --git a/tests/golden/typecheck/traits/multi_trait_bound__plus_form_rejects_only_one.silt b/tests/golden/typecheck/traits/multi_trait_bound__plus_form_rejects_only_one.silt index 52ae2a997..b6fc16bce 100644 --- a/tests/golden/typecheck/traits/multi_trait_bound__plus_form_rejects_only_one.silt +++ b/tests/golden/typecheck/traits/multi_trait_bound__plus_form_rejects_only_one.silt @@ -5,9 +5,9 @@ trait MyEq { fn my_eq(self, other: Self) -> Bool } trait MyOrd { fn my_cmp(self, other: Self) -> Int } trait MyEq for String { fn my_eq(self, other: String) -> Bool { self == other } } fn use_both(x: a, y: a) -> Int where a: MyEq + MyOrd { - match x.my_eq(y) { + match MyEq.my_eq(x, y) { true -> 0 - false -> x.my_cmp(y) + false -> MyOrd.my_cmp(x, y) } } fn main() { println(use_both("a", "b")) } diff --git a/tests/golden/typecheck/traits/multi_trait_bound__three_bounds_accepts.silt b/tests/golden/typecheck/traits/multi_trait_bound__three_bounds_accepts.silt index b3af66834..3f06b9da8 100644 --- a/tests/golden/typecheck/traits/multi_trait_bound__three_bounds_accepts.silt +++ b/tests/golden/typecheck/traits/multi_trait_bound__three_bounds_accepts.silt @@ -16,8 +16,8 @@ trait MyOrd for Int { trait MyShow for Int { fn my_show(self) -> String { "int" } } fn use_three(x: a, y: a) -> String where a: MyEq + MyOrd + MyShow { - match x.my_eq(y) { - true -> x.my_show() + match MyEq.my_eq(x, y) { + true -> MyShow.my_show(x) false -> "diff" } } diff --git a/tests/golden/typecheck/traits/multi_trait_bound__three_bounds_rejects_last_missing.silt b/tests/golden/typecheck/traits/multi_trait_bound__three_bounds_rejects_last_missing.silt index d8198a23f..ec49d9724 100644 --- a/tests/golden/typecheck/traits/multi_trait_bound__three_bounds_rejects_last_missing.silt +++ b/tests/golden/typecheck/traits/multi_trait_bound__three_bounds_rejects_last_missing.silt @@ -8,8 +8,8 @@ trait MyShow { fn my_show(self) -> String } trait MyEq for Int { fn my_eq(self, other: Int) -> Bool { self == other } } trait MyOrd for Int { fn my_cmp(self, other: Int) -> Int { 0 } } fn use_three(x: a, y: a) -> String where a: MyEq + MyOrd + MyShow { - match x.my_eq(y) { - true -> x.my_show() + match MyEq.my_eq(x, y) { + true -> MyShow.my_show(x) false -> "diff" } } diff --git a/tests/golden/typecheck/traits/no_self__a_call_on_a_type_has_every_method.stderr b/tests/golden/typecheck/traits/no_self__a_call_on_a_type_has_every_method.stderr deleted file mode 100644 index 67b5d8cc3..000000000 --- a/tests/golden/typecheck/traits/no_self__a_call_on_a_type_has_every_method.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[type]: ambiguous method 'decode' on type 'String': provided by traits Mk, Rd - --> no_self__a_call_on_a_type_has_every_method.silt:49:19 - | - 49 | let t: String = String.decode(4) - | ^^^^^^^^^^^^^ ambiguous method 'decode' on type 'String': provided by traits Mk, Rd - = help: say which is meant: call it through a function bounded by the trait you mean, `where a: Mk` - -error[type]: method `make` takes no `self` — call it on the type instead: `Int.make(..)` - --> no_self__a_call_on_a_type_has_every_method.silt:51:11 - | - 51 | println(7.make(1)) - | ^^^^^^ method `make` takes no `self` — call it on the type instead: `Int.make(..)` diff --git a/tests/golden/typecheck/traits/no_self__a_method_without_self_is_no_candidate_on_a_value.silt b/tests/golden/typecheck/traits/no_self__a_method_without_self_is_no_candidate_on_a_value.silt index 36c5be257..a131a3d4e 100644 --- a/tests/golden/typecheck/traits/no_self__a_method_without_self_is_no_candidate_on_a_value.silt +++ b/tests/golden/typecheck/traits/no_self__a_method_without_self_is_no_candidate_on_a_value.silt @@ -42,11 +42,11 @@ trait Rd for P { } fn bounded(x: a) -> Int where a: Mk, a: Rd { - x.decode(10) + Rd.decode(x, 10) } fn unknown(x) { - x.decode(20) + Rd.decode(x, 20) } fn first(x: a) -> a { @@ -54,15 +54,15 @@ fn first(x: a) -> a { } fn later(x: a) -> Int where a: Mk + Rd { - let f = { y -> first(y).decode(30) } + let f = { y -> Rd.decode(first(y), 30) } f(x) } fn main() { let s = "a" - println(s.decode(3)) + println(Rd.decode(s, 3)) println(bounded(s)) println(unknown(s)) println(later(s)) - println(P { n: 5 }.decode(40)) + println(Rd.decode(P { n: 5 }, 40)) } diff --git a/tests/golden/typecheck/traits/parameterized_traits__concrete_method_call.silt b/tests/golden/typecheck/traits/parameterized_traits__concrete_method_call.silt index 935837a3d..7554c340f 100644 --- a/tests/golden/typecheck/traits/parameterized_traits__concrete_method_call.silt +++ b/tests/golden/typecheck/traits/parameterized_traits__concrete_method_call.silt @@ -14,6 +14,6 @@ trait Convertible(Int) for String { } fn main() { - let n: Int = "42".convert() + let n: Int = Convertible.convert("42") println(n) } diff --git a/tests/golden/typecheck/traits/parameterized_traits__generic_fn_constraint.silt b/tests/golden/typecheck/traits/parameterized_traits__generic_fn_constraint.silt index a4b33f85d..a27e30c85 100644 --- a/tests/golden/typecheck/traits/parameterized_traits__generic_fn_constraint.silt +++ b/tests/golden/typecheck/traits/parameterized_traits__generic_fn_constraint.silt @@ -14,7 +14,7 @@ trait Convertible(Int) for String { } fn unpack(x: a, type b) -> b where a: Convertible(b) { - x.convert() + Convertible.convert(x) } fn main() { diff --git a/tests/golden/typecheck/traits/parameterized_traits__multiple_impls.silt b/tests/golden/typecheck/traits/parameterized_traits__multiple_impls.silt index 6b7a1dfed..c34e17774 100644 --- a/tests/golden/typecheck/traits/parameterized_traits__multiple_impls.silt +++ b/tests/golden/typecheck/traits/parameterized_traits__multiple_impls.silt @@ -11,8 +11,8 @@ trait Wrap(String) for String { } fn main() { - let a: Int = 1.wrap() - let b: String = "x".wrap() + let a: Int = Wrap.wrap(1) + let b: String = Wrap.wrap("x") println(a) println(b) } diff --git a/tests/golden/typecheck/traits/recursive_trait_dispatch__chained_cross_trait.silt b/tests/golden/typecheck/traits/recursive_trait_dispatch__chained_cross_trait.silt index e62b94747..9c30807ce 100644 --- a/tests/golden/typecheck/traits/recursive_trait_dispatch__chained_cross_trait.silt +++ b/tests/golden/typecheck/traits/recursive_trait_dispatch__chained_cross_trait.silt @@ -4,6 +4,6 @@ trait Quadruple { fn quad(self) -> Int } trait Halve for Int { fn halve(self) -> Int { self / 2 } } trait Double for Int { fn double(self) -> Int { self * 2 } } -trait Quadruple for Int { fn quad(self) -> Int { self.double().double() } } +trait Quadruple for Int { fn quad(self) -> Int { Double.double(Double.double(self)) } } -fn main() { println((5).quad()) } +fn main() { println(Quadruple.quad(5)) } diff --git a/tests/golden/typecheck/traits/recursive_trait_dispatch__cross_trait_on_self.silt b/tests/golden/typecheck/traits/recursive_trait_dispatch__cross_trait_on_self.silt index ef916e5f2..8dae3edc3 100644 --- a/tests/golden/typecheck/traits/recursive_trait_dispatch__cross_trait_on_self.silt +++ b/tests/golden/typecheck/traits/recursive_trait_dispatch__cross_trait_on_self.silt @@ -5,7 +5,7 @@ trait Loud for Int { fn loud(self) -> String { "INT" } } trait Combined { fn combined(self) -> String } trait Combined for Int { - fn combined(self) -> String { "{self.greet()}-{self.loud()}" } + fn combined(self) -> String { "{Greet.greet(self)}-{Loud.loud(self)}" } } -fn main() { println((1).combined()) } +fn main() { println(Combined.combined(1)) } diff --git a/tests/golden/typecheck/traits/recursive_trait_dispatch__nested_box.silt b/tests/golden/typecheck/traits/recursive_trait_dispatch__nested_box.silt index 5b89eeca5..da1789e26 100644 --- a/tests/golden/typecheck/traits/recursive_trait_dispatch__nested_box.silt +++ b/tests/golden/typecheck/traits/recursive_trait_dispatch__nested_box.silt @@ -3,8 +3,8 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "leaf" } } trait Greet for Box(a) where a: Greet { fn greet(self) -> String { - match self { Box(inner) -> "[{inner.greet()}]" } + match self { Box(inner) -> "[{Greet.greet(inner)}]" } } } -fn main() { println(Box(Box(99)).greet()) } +fn main() { println(Greet.greet(Box(Box(99)))) } diff --git a/tests/golden/typecheck/traits/recursive_trait_dispatch__nested_box_rejects_innermost.silt b/tests/golden/typecheck/traits/recursive_trait_dispatch__nested_box_rejects_innermost.silt index a7c6ba663..aaa693d20 100644 --- a/tests/golden/typecheck/traits/recursive_trait_dispatch__nested_box_rejects_innermost.silt +++ b/tests/golden/typecheck/traits/recursive_trait_dispatch__nested_box_rejects_innermost.silt @@ -6,11 +6,11 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "leaf" } } trait Greet for Box(a) where a: Greet { fn greet(self) -> String { - match self { Box(inner) -> "[{inner.greet()}]" } + match self { Box(inner) -> "[{Greet.greet(inner)}]" } } } fn main() { let b = Box(Box("x")) - println(b.greet()) + println(Greet.greet(b)) } diff --git a/tests/golden/typecheck/traits/recursive_trait_dispatch__same_trait_through_other_impl.silt b/tests/golden/typecheck/traits/recursive_trait_dispatch__same_trait_through_other_impl.silt index 2a612bf88..211996754 100644 --- a/tests/golden/typecheck/traits/recursive_trait_dispatch__same_trait_through_other_impl.silt +++ b/tests/golden/typecheck/traits/recursive_trait_dispatch__same_trait_through_other_impl.silt @@ -3,8 +3,8 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int-leaf" } } trait Greet for Box(a) where a: Greet { fn greet(self) -> String { - match self { Box(inner) -> "box({inner.greet()})" } + match self { Box(inner) -> "box({Greet.greet(inner)})" } } } -fn main() { println(Box(7).greet()) } +fn main() { println(Greet.greet(Box(7))) } diff --git a/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__list_arg.silt b/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__list_arg.silt index bb89da4f6..6147040ba 100644 --- a/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__list_arg.silt +++ b/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__list_arg.silt @@ -4,9 +4,9 @@ trait Carry(c) { fn carry(self) -> c } trait Holds(b): Carry(List(b)) { fn hold(self) -> b } trait Carry(List(Int)) for Bag { fn carry(self) -> List(Int) { [1, 2] } } trait Holds(Int) for Bag { fn hold(self) -> Int { 1 } } -fn first_carried(x: t) -> List(Int) where t: Holds(Int) { x.carry() } +fn first_carried(x: t) -> List(Int) where t: Holds(Int) { Carry.carry(x) } fn main() { let b = Bag { n: 1 } - println("{b.hold()}") + println("{Holds.hold(b)}") println("{first_carried(b)}") } diff --git a/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__map_arg.silt b/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__map_arg.silt index 0d9bc1364..2924071fe 100644 --- a/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__map_arg.silt +++ b/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__map_arg.silt @@ -6,6 +6,6 @@ trait Carry(Map(String, Int)) for Bag { fn carry(self) -> Map(String, Int) { #{" trait Holds(Int) for Bag { fn hold(self) -> Int { 1 } } fn main() { let b = Bag { n: 1 } - println("{b.hold()}") - println("{b.carry()}") + println("{Holds.hold(b)}") + println("{Carry.carry(b)}") } diff --git a/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__mismatched_list_arg_rejected.silt b/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__mismatched_list_arg_rejected.silt index 52965db2c..0a121514f 100644 --- a/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__mismatched_list_arg_rejected.silt +++ b/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__mismatched_list_arg_rejected.silt @@ -8,4 +8,4 @@ trait Carry(c) { fn carry(self) -> c } trait Holds(b): Carry(List(b)) { fn hold(self) -> b } trait Carry(List(String)) for Bag { fn carry(self) -> List(String) { ["x"] } } trait Holds(Int) for Bag { fn hold(self) -> Int { 1 } } -fn main() { println("{(Bag { n: 1 }).hold()}") } +fn main() { println("{Holds.hold(Bag { n: 1 })}") } diff --git a/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__unit_arg.silt b/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__unit_arg.silt index 2f5adb1ff..363a28a67 100644 --- a/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__unit_arg.silt +++ b/tests/golden/typecheck/traits/round101_supertrait_container_arg_canon__unit_arg.silt @@ -4,4 +4,4 @@ trait Carry(c) { fn carry(self) -> c } trait Holds(b): Carry(Unit) { fn hold(self) -> b } trait Carry(Unit) for Bag { fn carry(self) -> Unit { () } } trait Holds(Int) for Bag { fn hold(self) -> Int { 1 } } -fn main() { println("{(Bag { n: 1 }).hold()}") } +fn main() { println("{Holds.hold(Bag { n: 1 })}") } diff --git a/tests/golden/typecheck/traits/round73_anon_record_trait_bypass__anon_record_rejected.silt b/tests/golden/typecheck/traits/round73_anon_record_trait_bypass__anon_record_rejected.silt index c34b6bdaa..541271141 100644 --- a/tests/golden/typecheck/traits/round73_anon_record_trait_bypass__anon_record_rejected.silt +++ b/tests/golden/typecheck/traits/round73_anon_record_trait_bypass__anon_record_rejected.silt @@ -6,7 +6,7 @@ -- stderr-contains: type '{x: Int, y: Int}' does not implement trait 'MyTrait' trait MyTrait { fn ident(self) -> Int } trait MyTrait for Int { fn ident(self) { self } } -fn use_it(x: a) -> Int where a: MyTrait { x.ident() } +fn use_it(x: a) -> Int where a: MyTrait { MyTrait.ident(x) } fn main() { let r = {x: 1, y: 2} println(use_it(r)) diff --git a/tests/golden/typecheck/traits/round73_anon_record_trait_bypass__nominal_record_rejected.silt b/tests/golden/typecheck/traits/round73_anon_record_trait_bypass__nominal_record_rejected.silt index 211af83d9..866c9c135 100644 --- a/tests/golden/typecheck/traits/round73_anon_record_trait_bypass__nominal_record_rejected.silt +++ b/tests/golden/typecheck/traits/round73_anon_record_trait_bypass__nominal_record_rejected.silt @@ -6,7 +6,7 @@ trait MyTrait { fn ident(self) -> Int } trait MyTrait for Int { fn ident(self) { self } } type Foo { x: Int } -fn use_it(x: a) -> Int where a: MyTrait { x.ident() } +fn use_it(x: a) -> Int where a: MyTrait { MyTrait.ident(x) } fn main() { let r = Foo { x: 1 } println(use_it(r)) diff --git a/tests/golden/typecheck/traits/round74_unit_trait_dispatch__user_trait_for_unit.silt b/tests/golden/typecheck/traits/round74_unit_trait_dispatch__user_trait_for_unit.silt index 469224bda..0bb2b24c9 100644 --- a/tests/golden/typecheck/traits/round74_unit_trait_dispatch__user_trait_for_unit.silt +++ b/tests/golden/typecheck/traits/round74_unit_trait_dispatch__user_trait_for_unit.silt @@ -3,5 +3,5 @@ trait Greet { fn greet(self) -> String } trait Greet for Unit { fn greet(self) -> String { "hi" } } fn main() { let u = () - println(u.greet()) + println(Greet.greet(u)) } diff --git a/tests/golden/typecheck/traits/round76_trait_impl_subst__broken_program_prints_nothing.silt b/tests/golden/typecheck/traits/round76_trait_impl_subst__broken_program_prints_nothing.silt index f08593559..1ba1ab185 100644 --- a/tests/golden/typecheck/traits/round76_trait_impl_subst__broken_program_prints_nothing.silt +++ b/tests/golden/typecheck/traits/round76_trait_impl_subst__broken_program_prints_nothing.silt @@ -5,7 +5,7 @@ trait Foo(a) { fn produce(self) -> a } trait Foo(Int) for String { fn produce(self) -> String { "haha" } } fn use_foo(s: a) -> Int where a: Foo(Int) { - s.produce() + Foo.produce(s) } fn main() { let s: String = "hi" diff --git a/tests/golden/typecheck/traits/round76_trait_impl_subst__matching_signature_ok.silt b/tests/golden/typecheck/traits/round76_trait_impl_subst__matching_signature_ok.silt index 1276f892f..d96cd797c 100644 --- a/tests/golden/typecheck/traits/round76_trait_impl_subst__matching_signature_ok.silt +++ b/tests/golden/typecheck/traits/round76_trait_impl_subst__matching_signature_ok.silt @@ -1,7 +1,7 @@ trait Foo(a) { fn produce(self) -> a } trait Foo(Int) for String { fn produce(self) -> Int { 42 } } fn use_foo(s: a) -> Int where a: Foo(Int) { - s.produce() + Foo.produce(s) } fn main() { let s: String = "hi" diff --git a/tests/golden/typecheck/traits/round76_trait_impl_subst__signature_mismatch_rejected.silt b/tests/golden/typecheck/traits/round76_trait_impl_subst__signature_mismatch_rejected.silt index 7d5a08f4b..78c66dac2 100644 --- a/tests/golden/typecheck/traits/round76_trait_impl_subst__signature_mismatch_rejected.silt +++ b/tests/golden/typecheck/traits/round76_trait_impl_subst__signature_mismatch_rejected.silt @@ -4,7 +4,7 @@ trait Foo(a) { fn produce(self) -> a } trait Foo(Int) for String { fn produce(self) -> String { "haha" } } fn use_foo(s: a) -> Int where a: Foo(Int) { - s.produce() + Foo.produce(s) } fn main() { let s: String = "hi" diff --git a/tests/golden/typecheck/traits/round79_typechecker_fixes__anon_record_trait_arg.silt b/tests/golden/typecheck/traits/round79_typechecker_fixes__anon_record_trait_arg.silt index eab2eb2ba..6e48917a4 100644 --- a/tests/golden/typecheck/traits/round79_typechecker_fixes__anon_record_trait_arg.silt +++ b/tests/golden/typecheck/traits/round79_typechecker_fixes__anon_record_trait_arg.silt @@ -5,7 +5,7 @@ trait Convert({a: Int, b: String}) for Int { fn convert(self) -> {a: Int, b: String} { {a: self, b: "x"} } } fn use_it(x: a) -> Int where a: Convert({a: Int, b: String}) { - let r = x.convert() + let r = Convert.convert(x) r.a } fn main() { println(use_it(7)) } diff --git a/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_enum_in_supertrait.silt b/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_enum_in_supertrait.silt index b69a33a51..e8593fcf1 100644 --- a/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_enum_in_supertrait.silt +++ b/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_enum_in_supertrait.silt @@ -6,7 +6,7 @@ trait Carry(t) { fn carry(self, x: t) -> t } trait Holds: Carry(Box) { fn hold(self) -> Int } fn use_holds(x: t) -> Int where t: Holds { - x.hold() + Holds.hold(x) } fn main() { } diff --git a/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_name_inside_generic_arg.silt b/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_name_inside_generic_arg.silt index b31e4bce6..abc6308f7 100644 --- a/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_name_inside_generic_arg.silt +++ b/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_name_inside_generic_arg.silt @@ -7,7 +7,7 @@ trait Carry(t) { fn carry(self, x: t) -> t } trait Holds: Carry(List(Box)) { fn hold(self) -> Int } fn use_holds(x: t) -> Int where t: Holds { - x.hold() + Holds.hold(x) } fn main() { } diff --git a/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_record_in_supertrait.silt b/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_record_in_supertrait.silt index 3c1bc7348..9d7b18d45 100644 --- a/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_record_in_supertrait.silt +++ b/tests/golden/typecheck/traits/round88_supertrait_arg_arity__bare_record_in_supertrait.silt @@ -6,7 +6,7 @@ trait Carry(t) { fn carry(self, x: t) -> t } trait Holds: Carry(Wrapper) { fn hold(self) -> Int } fn use_holds(x: t) -> Int where t: Holds { - x.hold() + Holds.hold(x) } fn main() { } diff --git a/tests/golden/typecheck/traits/round88_supertrait_arg_arity__enum_with_args_ok.silt b/tests/golden/typecheck/traits/round88_supertrait_arg_arity__enum_with_args_ok.silt index 86a4ff0c7..0b7bee6fb 100644 --- a/tests/golden/typecheck/traits/round88_supertrait_arg_arity__enum_with_args_ok.silt +++ b/tests/golden/typecheck/traits/round88_supertrait_arg_arity__enum_with_args_ok.silt @@ -6,7 +6,7 @@ trait Carry(t) { fn carry(self, x: t) -> t } trait Holds: Carry(Box(Int)) { fn hold(self) -> Int } fn use_holds(x: t) -> Int where t: Holds { - x.hold() + Holds.hold(x) } fn main() { } diff --git a/tests/golden/typecheck/traits/sealed_traits__derived_compare_equal_hash_and_hand_written_display.silt b/tests/golden/typecheck/traits/sealed_traits__derived_compare_equal_hash_and_hand_written_display.silt index 2b3ac1600..8eb4e4cdc 100644 --- a/tests/golden/typecheck/traits/sealed_traits__derived_compare_equal_hash_and_hand_written_display.silt +++ b/tests/golden/typecheck/traits/sealed_traits__derived_compare_equal_hash_and_hand_written_display.silt @@ -12,7 +12,7 @@ fn main() { let b = Version { major: 1, minor: 10 } println(a < b) println(a == Version { major: 1, minor: 2 }) - println(a.compare(b)) + println(Compare.compare(a, b)) println(map.get(#{ a: "old", b: "new" }, b)) - println(a.display()) + println("{a}") } diff --git a/tests/golden/typecheck/traits/structural_method__the_other_operand_is_of_the_receivers_type.silt b/tests/golden/typecheck/traits/structural_method__the_other_operand_is_of_the_receivers_type.silt index e4aa29f7d..3f10a99dc 100644 --- a/tests/golden/typecheck/traits/structural_method__the_other_operand_is_of_the_receivers_type.silt +++ b/tests/golden/typecheck/traits/structural_method__the_other_operand_is_of_the_receivers_type.silt @@ -1,20 +1,20 @@ -- cmd: check -- exit: 1 -- verdict: same --- `equal` and `compare` take a value of the receiver's type: comparing --- an Int with a String, or a record with a number, is a type mismatch --- and not a `false` (or an error when the program runs). +-- `Compare.compare` and `==` take two values of one type: comparing an +-- Int with a String, or a record with a number, is a type mismatch and +-- not a `false` (or an error when the program runs). type P { n: Int, } fn main() { let p = P { n: 1 } - println(1.equal("a")) - println(p.equal(2)) - println(p.compare("x")) - println([1].equal(["a"])) - println(Some(1).equal(Some("a"))) - println(1.equal(1)) - println(p.compare(P { n: 2 })) + println(Compare.compare(1, "a")) + println(p == 2) + println(Compare.compare(p, "x")) + println([1] == ["a"]) + println(Some(1) == Some("a")) + println(Compare.compare(1, 1)) + println(Compare.compare(p, P { n: 2 })) } diff --git a/tests/golden/typecheck/traits/structural_method__the_other_operand_is_of_the_receivers_type.stderr b/tests/golden/typecheck/traits/structural_method__the_other_operand_is_of_the_receivers_type.stderr index a8832b47e..2c35c07df 100644 --- a/tests/golden/typecheck/traits/structural_method__the_other_operand_is_of_the_receivers_type.stderr +++ b/tests/golden/typecheck/traits/structural_method__the_other_operand_is_of_the_receivers_type.stderr @@ -1,29 +1,29 @@ error[type]: type mismatch: expected Int, got String - --> structural_method__the_other_operand_is_of_the_receivers_type.silt:13:19 + --> structural_method__the_other_operand_is_of_the_receivers_type.silt:13:30 | - 13 | println(1.equal("a")) - | ^^^ type mismatch: expected Int, got String + 13 | println(Compare.compare(1, "a")) + | ^^^ type mismatch: expected Int, got String error[type]: type mismatch: expected P, got Int - --> structural_method__the_other_operand_is_of_the_receivers_type.silt:14:19 + --> structural_method__the_other_operand_is_of_the_receivers_type.silt:14:16 | - 14 | println(p.equal(2)) - | ^ type mismatch: expected P, got Int + 14 | println(p == 2) + | ^ type mismatch: expected P, got Int error[type]: type mismatch: expected P, got String - --> structural_method__the_other_operand_is_of_the_receivers_type.silt:15:21 + --> structural_method__the_other_operand_is_of_the_receivers_type.silt:15:30 | - 15 | println(p.compare("x")) - | ^^^ type mismatch: expected P, got String + 15 | println(Compare.compare(p, "x")) + | ^^^ type mismatch: expected P, got String error[type]: type mismatch: expected Int, got String - --> structural_method__the_other_operand_is_of_the_receivers_type.silt:16:21 + --> structural_method__the_other_operand_is_of_the_receivers_type.silt:16:18 | - 16 | println([1].equal(["a"])) - | ^^^^^ type mismatch: expected Int, got String + 16 | println([1] == ["a"]) + | ^^^^^ type mismatch: expected Int, got String error[type]: type mismatch: expected Int, got String - --> structural_method__the_other_operand_is_of_the_receivers_type.silt:17:25 + --> structural_method__the_other_operand_is_of_the_receivers_type.silt:17:22 | - 17 | println(Some(1).equal(Some("a"))) - | ^^^^^^^^^ type mismatch: expected Int, got String + 17 | println(Some(1) == Some("a")) + | ^^^^^^^^^ type mismatch: expected Int, got String diff --git a/tests/golden/typecheck/traits/structural_method__through_a_type_is_typed.silt b/tests/golden/typecheck/traits/structural_method__through_a_type_is_typed.silt deleted file mode 100644 index e53d278c5..000000000 --- a/tests/golden/typecheck/traits/structural_method__through_a_type_is_typed.silt +++ /dev/null @@ -1,23 +0,0 @@ --- cmd: check --- exit: 1 --- A method of a structural trait written through a type (`Int.display`, --- `P.compare`) or through a type held in a value has the type it has on --- a value of that type, with the receiver as its first argument: the --- arguments, their number and the result are checked. -import list - -type P { - x: Int, -} - -fn main() { - println(Int.equal(1, 2.0)) - println(P.display(5)) - let n: Int = String.display("s") - let names: List(Int) = list.map(["a", "b"], String.display) - let q = P - println(q.compare(P { x: 1 }, 3)) - println(Int.display()) - println(Tuple.display((1, 2))) - println("{n} {names}") -} diff --git a/tests/golden/typecheck/traits/structural_method__through_a_type_is_typed.stderr b/tests/golden/typecheck/traits/structural_method__through_a_type_is_typed.stderr deleted file mode 100644 index b8fe532b1..000000000 --- a/tests/golden/typecheck/traits/structural_method__through_a_type_is_typed.stderr +++ /dev/null @@ -1,41 +0,0 @@ -error[type]: type mismatch: expected Int, got Float - --> structural_method__through_a_type_is_typed.silt:14:24 - | - 14 | println(Int.equal(1, 2.0)) - | ^^^ type mismatch: expected Int, got Float - -error[type]: type mismatch: expected P, got Int - --> structural_method__through_a_type_is_typed.silt:15:21 - | - 15 | println(P.display(5)) - | ^ type mismatch: expected P, got Int - -error[type]: type mismatch: expected Int, got String - --> structural_method__through_a_type_is_typed.silt:16:16 - | - 16 | let n: Int = String.display("s") - | ^^^^^^^^^^^^^^^^^^^ type mismatch: expected Int, got String - -error[type]: type mismatch: expected Int, got String - --> structural_method__through_a_type_is_typed.silt:17:26 - | - 17 | let names: List(Int) = list.map(["a", "b"], String.display) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch: expected Int, got String - -error[type]: type mismatch: expected P, got Int - --> structural_method__through_a_type_is_typed.silt:19:33 - | - 19 | println(q.compare(P { x: 1 }, 3)) - | ^ type mismatch: expected P, got Int - -error[type]: function expects 1 argument, got 0 - --> structural_method__through_a_type_is_typed.silt:20:11 - | - 20 | println(Int.display()) - | ^^^^^^^^^^^^^ function expects 1 argument, got 0 - -error[type]: method `display` of the impl for every `Tuple` is called on a value: write `x.display(..)`, not `Tuple.display` - --> structural_method__through_a_type_is_typed.silt:21:11 - | - 21 | println(Tuple.display((1, 2))) - | ^^^^^^^^^^^^^ method `display` of the impl for every `Tuple` is called on a value: write `x.display(..)`, not `Tuple.display` diff --git a/tests/golden/typecheck/traits/structural_method__through_a_type_runs.silt b/tests/golden/typecheck/traits/structural_method__through_a_type_runs.silt index 971691c6e..6c953cad5 100644 --- a/tests/golden/typecheck/traits/structural_method__through_a_type_runs.silt +++ b/tests/golden/typecheck/traits/structural_method__through_a_type_runs.silt @@ -2,6 +2,7 @@ -- type held in a value, is the method of the type's values. import json import list +import string type P { x: Int, @@ -17,25 +18,25 @@ type Color { } fn shown(x: a, type a) -> String where a: Display { - a.display(x) + "{x}" } fn order(x: a, y: a, type a) -> Int where a: Compare { - a.compare(x, y) + Compare.compare(x, y) } fn main() { - println(Int.display(3)) - println(Option.display(Some(1))) - println(Box.display(Box { v: "b" })) - println(Color.compare(Red, Green)) - println(Float.equal(1.0, 1.0)) - println(json.Value.display(json.Null)) - println(list.map([1, 2], Int.display)) - println(list.fold([P { x: 2 }, P { x: 1 }], 0, { acc, p -> acc + P.compare(p, P { x: 1 }) })) + println("{3}") + println("{Some(1)}") + println(string.from(Box { v: "b" })) + println(Compare.compare(Red, Green)) + println(1.0 == 1.0) + println("{json.Null}") + println(list.map([1, 2], string.from)) + println(list.fold([P { x: 2 }, P { x: 1 }], 0, { acc, p -> acc + Compare.compare(p, P { x: 1 }) })) let q = P - println(q.display(P { x: 4 })) - println(Int.hash(3) == 3.hash()) + println(string.from(P { x: 4 })) + println(Hash.hash(3) == Hash.hash(3)) println(shown(P { x: 5 }, P)) println(order(2, 1, Int)) } diff --git a/tests/golden/typecheck/traits/structural_method__through_its_trait_is_typed.silt b/tests/golden/typecheck/traits/structural_method__through_its_trait_is_typed.silt new file mode 100644 index 000000000..3a7ed8897 --- /dev/null +++ b/tests/golden/typecheck/traits/structural_method__through_its_trait_is_typed.silt @@ -0,0 +1,21 @@ +-- cmd: check +-- exit: 1 +-- A method of a structural trait called through its trait +-- (`Compare.compare`, `Hash.hash`), or taken as a value, has the type it +-- has for a value of the argument's type: the arguments, their number +-- and the result are checked. +import list + +type P { + x: Int, +} + +fn main() { + println(Compare.compare(1, 2.0)) + let n: String = Hash.hash("s") + let hashes: List(String) = list.map(["a", "b"], Hash.hash) + println(Compare.compare(P { x: 1 }, 3)) + println(Compare.compare()) + println(Hash.hash((1, 2))) + println("{n} {hashes}") +} diff --git a/tests/golden/typecheck/traits/structural_method__through_its_trait_is_typed.stderr b/tests/golden/typecheck/traits/structural_method__through_its_trait_is_typed.stderr new file mode 100644 index 000000000..986e3129c --- /dev/null +++ b/tests/golden/typecheck/traits/structural_method__through_its_trait_is_typed.stderr @@ -0,0 +1,29 @@ +error[type]: type mismatch: expected Int, got Float + --> structural_method__through_its_trait_is_typed.silt:14:30 + | + 14 | println(Compare.compare(1, 2.0)) + | ^^^ type mismatch: expected Int, got Float + +error[type]: type mismatch: expected String, got Int + --> structural_method__through_its_trait_is_typed.silt:15:19 + | + 15 | let n: String = Hash.hash("s") + | ^^^^^^^^^^^^^^ type mismatch: expected String, got Int + +error[type]: type mismatch: expected String, got Int + --> structural_method__through_its_trait_is_typed.silt:16:30 + | + 16 | let hashes: List(String) = list.map(["a", "b"], Hash.hash) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch: expected String, got Int + +error[type]: type mismatch: expected P, got Int + --> structural_method__through_its_trait_is_typed.silt:17:39 + | + 17 | println(Compare.compare(P { x: 1 }, 3)) + | ^ type mismatch: expected P, got Int + +error[type]: `Compare.compare` expects 2 arguments, got 0 + --> structural_method__through_its_trait_is_typed.silt:18:11 + | + 18 | println(Compare.compare()) + | ^^^^^^^^^^^^^^^^^ `Compare.compare` expects 2 arguments, got 0 diff --git a/tests/golden/typecheck/traits/structural_trait__one_answer_for_a_method_a_supertrait_a_bound_and_an_operator.silt b/tests/golden/typecheck/traits/structural_trait__one_answer_for_a_method_a_supertrait_a_bound_and_an_operator.silt index b3f508146..67d3f9820 100644 --- a/tests/golden/typecheck/traits/structural_trait__one_answer_for_a_method_a_supertrait_a_bound_and_an_operator.silt +++ b/tests/golden/typecheck/traits/structural_trait__one_answer_for_a_method_a_supertrait_a_bound_and_an_operator.silt @@ -35,12 +35,12 @@ fn same(a: a, b: a) -> Bool where a: Equal { fn main() { let p = Plain { n: 1 } - println(p.equal(p)) + println(p == p) println(same(p, p)) println(p == p) - println(p.rank()) + println(Ranked.rank(p)) let h = Held { f: { x -> x } } - println(h.equal(h)) + println(h == h) println(same(h, h)) println(h == h) } diff --git a/tests/golden/typecheck/traits/structural_trait__one_answer_for_a_method_a_supertrait_a_bound_and_an_operator.stderr b/tests/golden/typecheck/traits/structural_trait__one_answer_for_a_method_a_supertrait_a_bound_and_an_operator.stderr index 25f5deaaf..e435ce527 100644 --- a/tests/golden/typecheck/traits/structural_trait__one_answer_for_a_method_a_supertrait_a_bound_and_an_operator.stderr +++ b/tests/golden/typecheck/traits/structural_trait__one_answer_for_a_method_a_supertrait_a_bound_and_an_operator.stderr @@ -7,8 +7,8 @@ error[type]: type 'Held' implements 'Ranked' but does not implement supertrait ' error[type]: type 'Held' does not implement trait 'Equal': field 'f' is of type 'Fn(Int) -> Int', which does not --> structural_trait__one_answer_for_a_method_a_supertrait_a_bound_and_an_operator.silt:43:11 | - 43 | println(h.equal(h)) - | ^^^^^^^ type 'Held' does not implement trait 'Equal': field 'f' is of type 'Fn(Int) -> Int', which does not + 43 | println(h == h) + | ^^^^^^ type 'Held' does not implement trait 'Equal': field 'f' is of type 'Fn(Int) -> Int', which does not error[type]: type 'Held' does not implement trait 'Equal': field 'f' is of type 'Fn(Int) -> Int', which does not --> structural_trait__one_answer_for_a_method_a_supertrait_a_bound_and_an_operator.silt:44:16 diff --git a/tests/golden/typecheck/traits/structure__compare_method_on_structured_types.silt b/tests/golden/typecheck/traits/structure__compare_method_on_structured_types.silt index 66001f490..267c6d500 100644 --- a/tests/golden/typecheck/traits/structure__compare_method_on_structured_types.silt +++ b/tests/golden/typecheck/traits/structure__compare_method_on_structured_types.silt @@ -2,9 +2,9 @@ -- has the trait by its structure. type Pt { x: Int, y: Int } fn main() { - println(Some(1).compare(Some(2))) - println(Ok(2).compare(Ok(1))) - println(None.equal(Some(1))) - println(Pt { x: 1, y: 2 }.compare(Pt { x: 1, y: 3 })) - println(Some((1, "a")).hash() == Some((1, "a")).hash()) + println(Compare.compare(Some(1), Some(2))) + println(Compare.compare(Ok(2), Ok(1))) + println(None == Some(1)) + println(Compare.compare(Pt { x: 1, y: 2 }, Pt { x: 1, y: 3 })) + println(Hash.hash(Some((1, "a"))) == Hash.hash(Some((1, "a")))) } diff --git a/tests/golden/typecheck/traits/structure__error_is_at_the_use_once.silt b/tests/golden/typecheck/traits/structure__error_is_at_the_use_once.silt index 0bb5627ed..bcedc5e8d 100644 --- a/tests/golden/typecheck/traits/structure__error_is_at_the_use_once.silt +++ b/tests/golden/typecheck/traits/structure__error_is_at_the_use_once.silt @@ -9,5 +9,5 @@ fn main() { let h = H { f: { n -> n } } println(Y(Box(h))) println(Z == Z) - println([Box(h)].display()) + println("{[Box(h)]}") } diff --git a/tests/golden/typecheck/traits/structure__error_is_at_the_use_once.stderr b/tests/golden/typecheck/traits/structure__error_is_at_the_use_once.stderr index 47313b214..1d524519d 100644 --- a/tests/golden/typecheck/traits/structure__error_is_at_the_use_once.stderr +++ b/tests/golden/typecheck/traits/structure__error_is_at_the_use_once.stderr @@ -11,7 +11,7 @@ error[type]: type 'E' does not implement trait 'Equal': variant 'X' payload #1 > | ^^^^^^ type 'E' does not implement trait 'Equal': variant 'X' payload #1 > variant 'Some' payload #1 is of type 'Fn(Int) -> Int', which does not error[type]: type 'List(Box(H))' does not implement trait 'Display': element > variant 'Box' payload #1 > field 'f' is of type 'Fn(Int) -> Int', which does not - --> structure__error_is_at_the_use_once.silt:12:11 + --> structure__error_is_at_the_use_once.silt:12:13 | - 12 | println([Box(h)].display()) - | ^^^^^^^^^^^^^^^^ type 'List(Box(H))' does not implement trait 'Display': element > variant 'Box' payload #1 > field 'f' is of type 'Fn(Int) -> Int', which does not + 12 | println("{[Box(h)]}") + | ^^^^^^^^ type 'List(Box(H))' does not implement trait 'Display': element > variant 'Box' payload #1 > field 'f' is of type 'Fn(Int) -> Int', which does not diff --git a/tests/golden/typecheck/traits/structure__written_display_impl_answers.silt b/tests/golden/typecheck/traits/structure__written_display_impl_answers.silt index e293b39af..23d318cc0 100644 --- a/tests/golden/typecheck/traits/structure__written_display_impl_answers.silt +++ b/tests/golden/typecheck/traits/structure__written_display_impl_answers.silt @@ -4,7 +4,7 @@ type Job { name: String, run: Fn(Int) -> Int } trait Display for Job { fn display(self) -> String { "job {self.name}" } } type Box(a) { Box(a) } trait Display for Box(a) where a: Display { fn display(self) -> String { match self { Box(v) -> "box of {v}" } } } -fn show(x: a) -> String where a: Display { x.display() } +fn show(x: a) -> String where a: Display { "{x}" } fn main() { let j = Job { name: "j", run: { n -> n } } println(show(j)) diff --git a/tests/golden/typecheck/traits/structure__written_display_impl_header_owed.silt b/tests/golden/typecheck/traits/structure__written_display_impl_header_owed.silt index e5e0f9459..305914cb2 100644 --- a/tests/golden/typecheck/traits/structure__written_display_impl_header_owed.silt +++ b/tests/golden/typecheck/traits/structure__written_display_impl_header_owed.silt @@ -3,7 +3,7 @@ -- stderr-contains: error[type]: type 'Fn' does not implement trait 'Display' type Box(a) { Box(a) } trait Display for Box(a) where a: Display { fn display(self) -> String { match self { Box(v) -> "box of {v}" } } } -fn show(x: a) -> String where a: Display { x.display() } +fn show(x: a) -> String where a: Display { "{x}" } fn main() { println(show([Box({ n -> n })])) } diff --git a/tests/golden/typecheck/traits/supertrait__multiple_all_satisfied.silt b/tests/golden/typecheck/traits/supertrait__multiple_all_satisfied.silt index 796530e32..068c41295 100644 --- a/tests/golden/typecheck/traits/supertrait__multiple_all_satisfied.silt +++ b/tests/golden/typecheck/traits/supertrait__multiple_all_satisfied.silt @@ -20,10 +20,10 @@ trait Tr2 for Baz { fn t2(self) -> Int { self.v + 1 } } trait Both for Baz { - fn both(self) -> Int { self.t1() + self.t2() } + fn both(self) -> Int { Tr1.t1(self) + Tr2.t2(self) } } fn main() { let b = Baz { v: 5 } - println(b.both()) + println(Both.both(b)) } diff --git a/tests/golden/typecheck/traits/supertrait__runtime_dispatch_through_constraint.silt b/tests/golden/typecheck/traits/supertrait__runtime_dispatch_through_constraint.silt index cbaf680d0..71c56ed39 100644 --- a/tests/golden/typecheck/traits/supertrait__runtime_dispatch_through_constraint.silt +++ b/tests/golden/typecheck/traits/supertrait__runtime_dispatch_through_constraint.silt @@ -18,9 +18,9 @@ trait Ord2 for Foo { } fn label(a: t, b: t) -> String where t: Ord2 { - match a.eq2(b) { + match Eq2.eq2(a, b) { true -> "equal" - false -> match a.lt2(b) { + false -> match Ord2.lt2(a, b) { true -> "less" false -> "greater" } diff --git a/tests/golden/typecheck/traits/supertrait__transitive_methods_through_where.silt b/tests/golden/typecheck/traits/supertrait__transitive_methods_through_where.silt index 8e0cbc768..a6bdc7e5b 100644 --- a/tests/golden/typecheck/traits/supertrait__transitive_methods_through_where.silt +++ b/tests/golden/typecheck/traits/supertrait__transitive_methods_through_where.silt @@ -29,7 +29,7 @@ trait C1 for Bar { -- All three method calls must resolve via the C1 -> B1 -> A1 chain. fn use_all(x: t) -> Int where t: C1 { - x.a1() + x.b1() + x.c1() + A1.a1(x) + B1.b1(x) + C1.c1(x) } fn main() { diff --git a/tests/golden/typecheck/traits/supertrait__where_subtrait_enables_supertrait_methods.silt b/tests/golden/typecheck/traits/supertrait__where_subtrait_enables_supertrait_methods.silt index 899ee674b..751accff7 100644 --- a/tests/golden/typecheck/traits/supertrait__where_subtrait_enables_supertrait_methods.silt +++ b/tests/golden/typecheck/traits/supertrait__where_subtrait_enables_supertrait_methods.silt @@ -21,9 +21,9 @@ trait Ord2 for Foo { -- This should typecheck because Eq2 is a supertrait of Ord2. fn cmp(a: t, b: t) -> Bool where t: Ord2 { - match a.eq2(b) { + match Eq2.eq2(a, b) { true -> false - false -> a.lt2(b) + false -> Ord2.lt2(a, b) } } diff --git a/tests/golden/typecheck/traits/no_self__a_call_on_a_type_has_every_method.silt b/tests/golden/typecheck/traits/through_the_type__a_method_that_makes_a_value.silt similarity index 56% rename from tests/golden/typecheck/traits/no_self__a_call_on_a_type_has_every_method.silt rename to tests/golden/typecheck/traits/through_the_type__a_method_that_makes_a_value.silt index 4ad15457a..3258c46c4 100644 --- a/tests/golden/typecheck/traits/no_self__a_call_on_a_type_has_every_method.silt +++ b/tests/golden/typecheck/traits/through_the_type__a_method_that_makes_a_value.silt @@ -1,10 +1,11 @@ -- cmd: check -- exit: 1 --- The rule that a method without `self` is no candidate is for a call --- on a value: a call on the type (`String.decode(4)`) has both traits' --- methods, and is ambiguous. A call on a value of methods that all take --- no `self` has no candidate: it is refused as taking no `self`, with --- the call on the type to write. +-- Through the type a call means a method that makes a value: of a +-- method `decode` that makes a String and one that takes a String, +-- `String.decode(4)` is the first, with no ambiguity (the other is +-- called through its trait). Two traits that each give the type a +-- method `make` that makes a value are ambiguous, with the help to call +-- it through a bounded function. trait Mk { fn decode(v: Int) -> Self } @@ -48,5 +49,5 @@ trait Build for Int { fn main() { let t: String = String.decode(4) println(t) - println(7.make(1)) + println(Int.make(1)) } diff --git a/tests/golden/typecheck/traits/through_the_type__a_method_that_makes_a_value.stderr b/tests/golden/typecheck/traits/through_the_type__a_method_that_makes_a_value.stderr new file mode 100644 index 000000000..33e7f8edb --- /dev/null +++ b/tests/golden/typecheck/traits/through_the_type__a_method_that_makes_a_value.stderr @@ -0,0 +1,6 @@ +error[type]: ambiguous method 'make' on type 'Int': provided by traits Build, Make + --> through_the_type__a_method_that_makes_a_value.silt:52:11 + | + 52 | println(Int.make(1)) + | ^^^^^^^^ ambiguous method 'make' on type 'Int': provided by traits Build, Make + = help: say which is meant: call it through a function bounded by the trait you mean, `where a: Build` diff --git a/tests/golden/typecheck/traits/trait_ambiguity__distinct_methods_same_type.silt b/tests/golden/typecheck/traits/trait_ambiguity__distinct_methods_same_type.silt index 31df93574..e820fd101 100644 --- a/tests/golden/typecheck/traits/trait_ambiguity__distinct_methods_same_type.silt +++ b/tests/golden/typecheck/traits/trait_ambiguity__distinct_methods_same_type.silt @@ -6,6 +6,6 @@ trait B { fn beta(self) -> Int } trait A for Int { fn alpha(self) -> Int { 1 } } trait B for Int { fn beta(self) -> Int { 2 } } fn main() { - println((5).alpha()) - println((5).beta()) + println(A.alpha(5)) + println(B.beta(5)) } diff --git a/tests/golden/typecheck/traits/trait_ambiguity__names_both_traits.silt b/tests/golden/typecheck/traits/trait_ambiguity__names_both_traits.silt deleted file mode 100644 index f1f6e22c5..000000000 --- a/tests/golden/typecheck/traits/trait_ambiguity__names_both_traits.silt +++ /dev/null @@ -1,13 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: ambiguous method 'render' --- stderr-contains: 'String' --- stderr-contains: Display1 --- stderr-contains: Display2 --- The ambiguity diagnostic, at a call that sees both traits, names the --- method, the type and both traits. -trait Display1 { fn render(self) -> String } -trait Display2 { fn render(self) -> String } -trait Display1 for String { fn render(self) -> String { "1" } } -trait Display2 for String { fn render(self) -> String { "2" } } -fn main() { println("s".render()) } diff --git a/tests/golden/typecheck/traits/trait_ambiguity__same_method_different_types.silt b/tests/golden/typecheck/traits/trait_ambiguity__same_method_different_types.silt index 8ff4e0c66..6473404e3 100644 --- a/tests/golden/typecheck/traits/trait_ambiguity__same_method_different_types.silt +++ b/tests/golden/typecheck/traits/trait_ambiguity__same_method_different_types.silt @@ -6,6 +6,6 @@ trait B { fn show(self) -> String } trait A for Int { fn show(self) -> String { "int" } } trait B for String { fn show(self) -> String { self } } fn main() { - println((5).show()) - println(("hi").show()) + println(A.show(5)) + println(B.show("hi")) } diff --git a/tests/golden/typecheck/traits/trait_ambiguity__same_method_same_type.silt b/tests/golden/typecheck/traits/trait_ambiguity__same_method_same_type.silt deleted file mode 100644 index b85eadec9..000000000 --- a/tests/golden/typecheck/traits/trait_ambiguity__same_method_same_type.silt +++ /dev/null @@ -1,10 +0,0 @@ --- cmd: check --- exit: 1 --- stderr-contains: ambiguous method 'show' on type 'Int': provided by traits A, B --- Two traits providing `show` both implemented for Int: a call that --- sees both is ambiguous. -trait A { fn show(self) -> String } -trait B { fn show(self) -> String } -trait A for Int { fn show(self) -> String { "from-A" } } -trait B for Int { fn show(self) -> String { "from-B" } } -fn main() { println(5.show()) } diff --git a/tests/golden/typecheck/traits/trait_ambiguity__same_trait_multiple_types.silt b/tests/golden/typecheck/traits/trait_ambiguity__same_trait_multiple_types.silt index c686950cd..11a3e110d 100644 --- a/tests/golden/typecheck/traits/trait_ambiguity__same_trait_multiple_types.silt +++ b/tests/golden/typecheck/traits/trait_ambiguity__same_trait_multiple_types.silt @@ -11,7 +11,7 @@ trait Show for Bool { } } } fn main() { - println((1).show()) - println(("x").show()) - println(true.show()) + println(Show.show(1)) + println(Show.show("x")) + println(Show.show(true)) } diff --git a/tests/golden/typecheck/traits/trait_fn_name_collision__impl_method_still_works.silt b/tests/golden/typecheck/traits/trait_fn_name_collision__impl_method_still_works.silt index d8d0ee1fb..c3d4441ea 100644 --- a/tests/golden/typecheck/traits/trait_fn_name_collision__impl_method_still_works.silt +++ b/tests/golden/typecheck/traits/trait_fn_name_collision__impl_method_still_works.silt @@ -1,4 +1,4 @@ trait Showable { fn show(self) -> String } trait Showable for Int { fn show(self) -> String { "int" } } fn show(x) { x + 1 } -fn main() { println((5).show()) } +fn main() { println(Showable.show(5)) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__bare_target.silt b/tests/golden/typecheck/traits/trait_impl_params__bare_target.silt index 79fb99f3b..4af4792cc 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__bare_target.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__bare_target.silt @@ -1,3 +1,3 @@ trait Double { fn double(self) -> Int } trait Double for Int { fn double(self) -> Int { self * 2 } } -fn main() { println((5).double()) } +fn main() { println(Double.double(5)) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__bare_target_parameterized_record.silt b/tests/golden/typecheck/traits/trait_impl_params__bare_target_parameterized_record.silt index bedb02f0b..b8c0fb5a5 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__bare_target_parameterized_record.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__bare_target_parameterized_record.silt @@ -3,5 +3,5 @@ trait Tag { fn tag(self) -> String } trait Tag for Box { fn tag(self) -> String { "box" } } fn main() { let b = Box { value: 42 } - println(b.tag()) + println(Tag.tag(b)) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__distinct_element_types.silt b/tests/golden/typecheck/traits/trait_impl_params__distinct_element_types.silt index 20d4f325e..ef8ad6abe 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__distinct_element_types.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__distinct_element_types.silt @@ -6,5 +6,5 @@ trait Unwrap for Box(a) { fn main() { let b = Box(99) let c = Box("hello") - println(b.get() + c.get()) + println(Unwrap.get(b) + Unwrap.get(c)) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__enum_pattern_matches_self.silt b/tests/golden/typecheck/traits/trait_impl_params__enum_pattern_matches_self.silt index 7355073bd..c21014caf 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__enum_pattern_matches_self.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__enum_pattern_matches_self.silt @@ -7,5 +7,5 @@ trait Wrap for Box(a) { } fn main() { let b = Box(99) - println(b.unwrap()) + println(Wrap.unwrap(b)) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__impl_where_accepts_conforming.silt b/tests/golden/typecheck/traits/trait_impl_params__impl_where_accepts_conforming.silt index b64d29382..aaf3f402d 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__impl_where_accepts_conforming.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__impl_where_accepts_conforming.silt @@ -3,9 +3,9 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Greet for Box(a) where a: Greet { fn greet(self) -> String { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } fn main() { - println(Box(5).greet()) + println(Greet.greet(Box(5))) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__impl_where_comma_clauses.silt b/tests/golden/typecheck/traits/trait_impl_params__impl_where_comma_clauses.silt index aecda26fb..ea92fbd50 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__impl_where_comma_clauses.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__impl_where_comma_clauses.silt @@ -6,10 +6,10 @@ trait Loud for Int { fn loud(self) -> String { "INT" } } trait Greet for Box(a) where a: Greet, a: Loud { fn greet(self) -> String { match self { - Box(inner) -> "{inner.greet()}/{inner.loud()}" + Box(inner) -> "{Greet.greet(inner)}/{Loud.loud(inner)}" } } } fn main() { - println(Box(7).greet()) + println(Greet.greet(Box(7))) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__impl_where_partial_impl_rejected.silt b/tests/golden/typecheck/traits/trait_impl_params__impl_where_partial_impl_rejected.silt index 7fac70793..6dec5e80c 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__impl_where_partial_impl_rejected.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__impl_where_partial_impl_rejected.silt @@ -7,10 +7,10 @@ trait Loud { fn loud(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Greet for Box(a) where a: Greet + Loud { fn greet(self) -> String { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } fn main() { let b = Box(5) - println(b.greet()) + println(Greet.greet(b)) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__impl_where_plus_constraints.silt b/tests/golden/typecheck/traits/trait_impl_params__impl_where_plus_constraints.silt index 1326c7a98..50767e84f 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__impl_where_plus_constraints.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__impl_where_plus_constraints.silt @@ -6,10 +6,10 @@ trait Loud for Int { fn loud(self) -> String { "INT" } } trait Greet for Box(a) where a: Greet + Loud { fn greet(self) -> String { match self { - Box(inner) -> "{inner.greet()}-{inner.loud()}" + Box(inner) -> "{Greet.greet(inner)}-{Loud.loud(inner)}" } } } fn main() { - println(Box(42).greet()) + println(Greet.greet(Box(42))) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__impl_where_propagates_to_body.silt b/tests/golden/typecheck/traits/trait_impl_params__impl_where_propagates_to_body.silt index 128b18e3d..83d0daed9 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__impl_where_propagates_to_body.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__impl_where_propagates_to_body.silt @@ -3,9 +3,9 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int-greet" } } trait Greet for Box(a) where a: Greet { fn greet(self) -> String { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } fn main() { - println(Box(5).greet()) + println(Greet.greet(Box(5))) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__impl_where_rejects_violator.silt b/tests/golden/typecheck/traits/trait_impl_params__impl_where_rejects_violator.silt index 7d0b8447d..e096a1a26 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__impl_where_rejects_violator.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__impl_where_rejects_violator.silt @@ -6,10 +6,10 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Greet for Box(a) where a: Greet { fn greet(self) -> String { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } fn main() { let b = Box("hello") - println(b.greet()) + println(Greet.greet(b)) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__method_level_where_on_binder.silt b/tests/golden/typecheck/traits/trait_impl_params__method_level_where_on_binder.silt index 9ae6969be..f7b3a13c2 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__method_level_where_on_binder.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__method_level_where_on_binder.silt @@ -7,10 +7,10 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int-greet" } } trait Greet for Box(a) { fn greet(self) -> String where a: Greet { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } fn main() { let b = Box(5) - println(b.greet()) + println(Greet.greet(b)) } diff --git a/tests/golden/typecheck/traits/trait_impl_params__record_field_on_type_var.silt b/tests/golden/typecheck/traits/trait_impl_params__record_field_on_type_var.silt index 73e04a169..13f34ffc4 100644 --- a/tests/golden/typecheck/traits/trait_impl_params__record_field_on_type_var.silt +++ b/tests/golden/typecheck/traits/trait_impl_params__record_field_on_type_var.silt @@ -2,9 +2,9 @@ type Cell(a) { value: a } trait Peek { fn peek(self) -> Int } trait Peek for Int { fn peek(self) -> Int { self } } trait Peek for Cell(a) where a: Peek { - fn peek(self) -> Int { self.value.peek() } + fn peek(self) -> Int { Peek.peek(self.value) } } fn main() { let c = Cell { value: 42 } - println(c.peek()) + println(Peek.peek(c)) } diff --git a/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__monomorphic_return_two_sites.silt b/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__monomorphic_return_two_sites.silt index 323bf0053..9ba817925 100644 --- a/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__monomorphic_return_two_sites.silt +++ b/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__monomorphic_return_two_sites.silt @@ -10,8 +10,8 @@ trait Summarizable for Int { trait Summarizable for String { fn summarize(self) -> String { self } } -fn show_a(x: a) -> String where a: Summarizable { x.summarize() } -fn show_b(y: b) -> String where b: Summarizable { y.summarize() } +fn show_a(x: a) -> String where a: Summarizable { Summarizable.summarize(x) } +fn show_b(y: b) -> String where b: Summarizable { Summarizable.summarize(y) } fn main() { println(show_a(42)) println(show_b("hello")) diff --git a/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__polymorphic_return_two_sites.silt b/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__polymorphic_return_two_sites.silt index cb2c31c48..27571556f 100644 --- a/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__polymorphic_return_two_sites.silt +++ b/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__polymorphic_return_two_sites.silt @@ -13,8 +13,8 @@ trait Container(String) for StrBox { fn get_val(self) -> String { self.v } } -fn use_int(c: x) -> Int where x: Container(Int) { c.get_val() } -fn use_str(c: y) -> String where y: Container(String) { c.get_val() } +fn use_int(c: x) -> Int where x: Container(Int) { Container.get_val(c) } +fn use_str(c: y) -> String where y: Container(String) { Container.get_val(c) } fn main() { let a = IntBox { v: 42 } diff --git a/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__rejects_non_implementor.silt b/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__rejects_non_implementor.silt index 367229dd4..82e1eb531 100644 --- a/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__rejects_non_implementor.silt +++ b/tests/golden/typecheck/traits/trait_method_tyvar_instantiation__rejects_non_implementor.silt @@ -8,5 +8,5 @@ trait Measurable { trait Measurable for String { fn measure(self) -> Int { 0 } } -fn measure_it(x: a) -> Int where a: Measurable { x.measure() } +fn measure_it(x: a) -> Int where a: Measurable { Measurable.measure(x) } fn main() { println(measure_it(42)) } diff --git a/tests/golden/typecheck/traits/trait_param_polish__supertrait_arg_flows_to_super_method.silt b/tests/golden/typecheck/traits/trait_param_polish__supertrait_arg_flows_to_super_method.silt index 138379feb..aef91497c 100644 --- a/tests/golden/typecheck/traits/trait_param_polish__supertrait_arg_flows_to_super_method.silt +++ b/tests/golden/typecheck/traits/trait_param_polish__supertrait_arg_flows_to_super_method.silt @@ -17,7 +17,7 @@ trait Child(Int) for Holder { } fn call_parent(x: b, type a) -> a where b: Child(a) { - x.parent_fn() + Parent.parent_fn(x) } fn main() { diff --git a/tests/golden/typecheck/traits/trait_sig__impl_for_bare_target_is_for_every_argument.silt b/tests/golden/typecheck/traits/trait_sig__impl_for_bare_target_is_for_every_argument.silt index 102778483..d44b884d0 100644 --- a/tests/golden/typecheck/traits/trait_sig__impl_for_bare_target_is_for_every_argument.silt +++ b/tests/golden/typecheck/traits/trait_sig__impl_for_bare_target_is_for_every_argument.silt @@ -8,6 +8,6 @@ type Box(a) { Box(a) } trait Get { fn get(self) -> Int } trait Get for Box { fn get(self) -> Int { match self { Box(v) -> v } } } fn main() { - println(Box(1).get()) - println(Box("s").get() + 1) + println(Get.get(Box(1))) + println(Get.get(Box("s")) + 1) } diff --git a/tests/golden/typecheck/traits/trait_sig__impl_less_general_than_trait.silt b/tests/golden/typecheck/traits/trait_sig__impl_less_general_than_trait.silt index ac9fdcaf0..ca6f44c19 100644 --- a/tests/golden/typecheck/traits/trait_sig__impl_less_general_than_trait.silt +++ b/tests/golden/typecheck/traits/trait_sig__impl_less_general_than_trait.silt @@ -9,4 +9,4 @@ trait Wrap { fn wrap(self, x: a) -> List(a) } trait Wrap for Int { fn wrap(self, x: b) -> List(b) { [x] } } trait Wrap for Bool { fn wrap(self, x: Int) -> List(Int) { [x] } } -fn main() { println(1.wrap("s")) } +fn main() { println(Wrap.wrap(1, "s")) } diff --git a/tests/golden/typecheck/traits/trait_sig__method_where_clause_is_part_of_signature.silt b/tests/golden/typecheck/traits/trait_sig__method_where_clause_is_part_of_signature.silt index b71d49a63..08eed550b 100644 --- a/tests/golden/typecheck/traits/trait_sig__method_where_clause_is_part_of_signature.silt +++ b/tests/golden/typecheck/traits/trait_sig__method_where_clause_is_part_of_signature.silt @@ -4,21 +4,21 @@ trait Loud { fn loud(self) -> String } trait Loud for Int { fn loud(self) -> String { "INT" } } trait Shw { fn shw(self, x: a) -> String where a: Loud - fn twice(self, x: a) -> String where a: Loud { "{x.loud()}{x.loud()}" } + fn twice(self, x: a) -> String where a: Loud { "{Loud.loud(x)}{Loud.loud(x)}" } fn text(self, x: a) -> String where a: Display } trait Shw for Int { - fn shw(self, x) { x.loud() } - fn text(self, x) { x.display() } + fn shw(self, x) { Loud.loud(x) } + fn text(self, x) { "{x}" } } trait Shw for Bool { - fn shw(self, x: b) -> String where b: Loud { x.loud() } - fn text(self, x: b) -> String { "bool {x.display()}" } + fn shw(self, x: b) -> String where b: Loud { Loud.loud(x) } + fn text(self, x: b) -> String { "bool {x}" } } fn main() { - println(1.shw(2)) - println(true.shw(3)) - println(1.twice(4)) - println(1.text("s")) - println(true.text(5)) + println(Shw.shw(1, 2)) + println(Shw.shw(true, 3)) + println(Shw.twice(1, 4)) + println(Shw.text(1, "s")) + println(Shw.text(true, 5)) } diff --git a/tests/golden/typecheck/traits/trait_sig__method_where_clause_owed_by_callers.silt b/tests/golden/typecheck/traits/trait_sig__method_where_clause_owed_by_callers.silt index e4ebdc8ec..9a6a7a207 100644 --- a/tests/golden/typecheck/traits/trait_sig__method_where_clause_owed_by_callers.silt +++ b/tests/golden/typecheck/traits/trait_sig__method_where_clause_owed_by_callers.silt @@ -9,7 +9,7 @@ trait Loud { fn loud(self) -> String } trait Loud for Int { fn loud(self) -> String { "INT" } } trait Shw { fn shw(self, x: a) -> String where a: Loud } -trait Shw for Bool { fn shw(self, x) { x.loud() } } -fn call(s: t, v: String) -> String where t: Shw { s.shw(v) } -fn call_ok(s: t, v: Int) -> String where t: Shw { s.shw(v) } -fn main() { println(true.shw("s")) } +trait Shw for Bool { fn shw(self, x) { Loud.loud(x) } } +fn call(s: t, v: String) -> String where t: Shw { Shw.shw(s, v) } +fn call_ok(s: t, v: Int) -> String where t: Shw { Shw.shw(s, v) } +fn main() { println(Shw.shw(true, "s")) } diff --git a/tests/golden/typecheck/traits/trait_sig__no_return_type_is_unit.silt b/tests/golden/typecheck/traits/trait_sig__no_return_type_is_unit.silt index ad80c47f9..3fee2623b 100644 --- a/tests/golden/typecheck/traits/trait_sig__no_return_type_is_unit.silt +++ b/tests/golden/typecheck/traits/trait_sig__no_return_type_is_unit.silt @@ -6,4 +6,4 @@ -- stderr-contains: trait_sig__no_return_type_is_unit.silt:8:34 trait Sz { fn sz(self) } trait Sz for Int { fn sz(self) { "str" } } -fn main() { println(1.sz()) } +fn main() { println(Sz.sz(1)) } diff --git a/tests/golden/typecheck/traits/trait_sig__parameter_needs_annotation.silt b/tests/golden/typecheck/traits/trait_sig__parameter_needs_annotation.silt index 12bda860e..1fa11f407 100644 --- a/tests/golden/typecheck/traits/trait_sig__parameter_needs_annotation.silt +++ b/tests/golden/typecheck/traits/trait_sig__parameter_needs_annotation.silt @@ -7,4 +7,4 @@ -- stderr-contains: a trait declares complete signatures trait Mk { fn mk(self, other) -> Self } trait Mk for Int { fn mk(self, other) { other } } -fn main() { println(1.mk(2)) } +fn main() { println(Mk.mk(1, 2)) } diff --git a/tests/golden/typecheck/traits/trait_sig__unannotated_impl_method_has_trait_types.silt b/tests/golden/typecheck/traits/trait_sig__unannotated_impl_method_has_trait_types.silt index 91f3c59e5..c583eca40 100644 --- a/tests/golden/typecheck/traits/trait_sig__unannotated_impl_method_has_trait_types.silt +++ b/tests/golden/typecheck/traits/trait_sig__unannotated_impl_method_has_trait_types.silt @@ -8,5 +8,5 @@ trait Scale { fn scale(self, by: Int) -> Int } trait Scale for Int { fn scale(self, by) { self * by } } trait Scale for Bool { fn scale(self, by) { "unannotated string" } } -fn total(x: a, y: a) -> Int where a: Scale { x.scale(2) + y.scale(3) } +fn total(x: a, y: a) -> Int where a: Scale { Scale.scale(x, 2) + Scale.scale(y, 3) } fn main() { println(total(1, 2)) } diff --git a/tests/golden/typecheck/traits/two_traits_one_method_name__each_called_through_its_trait.silt b/tests/golden/typecheck/traits/two_traits_one_method_name__each_called_through_its_trait.silt new file mode 100644 index 000000000..4e576810e --- /dev/null +++ b/tests/golden/typecheck/traits/two_traits_one_method_name__each_called_through_its_trait.silt @@ -0,0 +1,10 @@ +-- Two traits providing `show`, both implemented for Int: each call names +-- its trait, so neither is ambiguous. +trait A { fn show(self) -> String } +trait B { fn show(self) -> String } +trait A for Int { fn show(self) -> String { "from-A" } } +trait B for Int { fn show(self) -> String { "from-B" } } +fn main() { + println(A.show(5)) + println(B.show(5)) +} diff --git a/tests/golden/typecheck/traits/two_traits_one_method_name__each_called_through_its_trait.stdout b/tests/golden/typecheck/traits/two_traits_one_method_name__each_called_through_its_trait.stdout new file mode 100644 index 000000000..0606a3e6d --- /dev/null +++ b/tests/golden/typecheck/traits/two_traits_one_method_name__each_called_through_its_trait.stdout @@ -0,0 +1,2 @@ +from-A +from-B diff --git a/tests/golden/typecheck/traits/type_descriptor_dispatch__generic_fn_body_with_constraint.silt b/tests/golden/typecheck/traits/type_descriptor_dispatch__generic_fn_body_with_constraint.silt index 4885b5c84..f5c045cea 100644 --- a/tests/golden/typecheck/traits/type_descriptor_dispatch__generic_fn_body_with_constraint.silt +++ b/tests/golden/typecheck/traits/type_descriptor_dispatch__generic_fn_body_with_constraint.silt @@ -14,7 +14,7 @@ trait Monoid for Int { } fn reduce(xs: List(a), type a) -> a where a: Monoid { - list.fold(xs, a.empty()) { acc, x -> a.combine(acc, x) } + list.fold(xs, a.empty()) { acc, x -> Monoid.combine(acc, x) } } fn use_it() { diff --git a/tests/golden/typecheck/traits/type_descriptor_dispatch__monoid_multi_arg.silt b/tests/golden/typecheck/traits/type_descriptor_dispatch__monoid_multi_arg.silt index 6a23296ea..604270536 100644 --- a/tests/golden/typecheck/traits/type_descriptor_dispatch__monoid_multi_arg.silt +++ b/tests/golden/typecheck/traits/type_descriptor_dispatch__monoid_multi_arg.silt @@ -13,7 +13,7 @@ trait Monoid for Int { fn use_it() { let e = Int.empty() - let c = Int.combine(1, 2) + let c = Monoid.combine(1, 2) } fn main() {} diff --git a/tests/golden/typecheck/traits/type_param_trait_impl__bad_descriptor_rejected.silt b/tests/golden/typecheck/traits/type_param_trait_impl__bad_descriptor_rejected.silt index b7194c8e0..1bddca18e 100644 --- a/tests/golden/typecheck/traits/type_param_trait_impl__bad_descriptor_rejected.silt +++ b/tests/golden/typecheck/traits/type_param_trait_impl__bad_descriptor_rejected.silt @@ -11,7 +11,7 @@ trait Tag for Int { } fn use_it() { - let _ = 42.tag("not a type") + let _ = Tag.tag(42, "not a type") } fn main() {} diff --git a/tests/golden/typecheck/traits/type_param_trait_impl__impl_type_param_dispatches.silt b/tests/golden/typecheck/traits/type_param_trait_impl__impl_type_param_dispatches.silt index cddcd4be9..7654840ee 100644 --- a/tests/golden/typecheck/traits/type_param_trait_impl__impl_type_param_dispatches.silt +++ b/tests/golden/typecheck/traits/type_param_trait_impl__impl_type_param_dispatches.silt @@ -16,7 +16,7 @@ trait Decodable for String { } fn use_it(body: String) { - let _ = body.decode(Todo) + let _ = Decodable.decode(body, Todo) } fn main() {} diff --git a/tests/golden/typecheck/traits/type_param_trait_impl__method_arg_offset.silt b/tests/golden/typecheck/traits/type_param_trait_impl__method_arg_offset.silt index 4b792fea2..4ee5e4dfb 100644 --- a/tests/golden/typecheck/traits/type_param_trait_impl__method_arg_offset.silt +++ b/tests/golden/typecheck/traits/type_param_trait_impl__method_arg_offset.silt @@ -18,7 +18,7 @@ fn use_it() { -- Passing a record type here exercises: receiver=Int flows -- into the self slot via dispatch_method_entry; the explicit -- arg Box unifies against the `type a` slot (params[1]). - let _ = 42.cast(Box) + let _ = Cast.cast(42, Box) } fn main() {} diff --git a/tests/golden/typecheck/traits/unified_trait_registration__error_default_message_synthesis.silt b/tests/golden/typecheck/traits/unified_trait_registration__error_default_message_synthesis.silt index 0d413ea1d..b58d3be4b 100644 --- a/tests/golden/typecheck/traits/unified_trait_registration__error_default_message_synthesis.silt +++ b/tests/golden/typecheck/traits/unified_trait_registration__error_default_message_synthesis.silt @@ -8,5 +8,5 @@ trait Error for MyErr {} fn main() { let e = Boom - println(e.message()) + println(Error.message(e)) } diff --git a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__compare_on_list.silt b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__compare_on_list.silt index afd1cb8d5..00faf273b 100644 --- a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__compare_on_list.silt +++ b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__compare_on_list.silt @@ -1,5 +1,5 @@ -- `.compare()` on List(Int) through a Compare bound orders element-wise. -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { let x: List(Int) = [1, 2, 3] let y: List(Int) = [1, 2, 4] diff --git a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__compare_on_unit.silt b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__compare_on_unit.silt index 03ca0cea6..ae44be97c 100644 --- a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__compare_on_unit.silt +++ b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__compare_on_unit.silt @@ -1,3 +1,3 @@ -- `.compare()` on Unit through a Compare bound is 0. -fn cmp_gen(a: a, b: a) -> Int where a: Compare { a.compare(b) } +fn cmp_gen(a: a, b: a) -> Int where a: Compare { Compare.compare(a, b) } fn main() { println(cmp_gen((), ())) } diff --git a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_deterministic.silt b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_deterministic.silt index b16affff6..b5535e335 100644 --- a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_deterministic.silt +++ b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_deterministic.silt @@ -1,5 +1,5 @@ -- Hashing the same Int twice gives the same result. -fn h(a: a) -> Int where a: Hash { a.hash() } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } fn main() { let a = h(42) let b = h(42) diff --git a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_err_string.silt b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_err_string.silt index 50411d2f8..0c5b6a777 100644 --- a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_err_string.silt +++ b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_err_string.silt @@ -1,3 +1,3 @@ -- `.hash()` through a Hash bound runs on a Result variant. -fn h(v: a) -> Int where a: Hash { v.hash() } +fn h(v: a) -> Int where a: Hash { Hash.hash(v) } fn main() { println(h(Err("boom")) == h(Err("boom"))) } diff --git a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_float_string_bool_list.silt b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_float_string_bool_list.silt index 589641667..6e4da06db 100644 --- a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_float_string_bool_list.silt +++ b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_float_string_bool_list.silt @@ -1,5 +1,5 @@ -- `.hash()` through a Hash bound runs on Float, String, Bool and List. -fn h(a: a) -> Int where a: Hash { a.hash() } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } fn main() { println(h(3.14) == h(3.14)) println(h("abc") == h("abc")) diff --git a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_int.silt b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_int.silt index cff8791d8..028408d1f 100644 --- a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_int.silt +++ b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_int.silt @@ -1,5 +1,5 @@ -- `.hash()` on Int through a Hash bound runs (the value itself is not pinned). -fn h(a: a) -> Int where a: Hash { a.hash() } +fn h(a: a) -> Int where a: Hash { Hash.hash(a) } fn main() { let v = h(42) println(v == v) diff --git a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_range.silt b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_range.silt index c102200f9..99e34016a 100644 --- a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_range.silt +++ b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_range.silt @@ -1,5 +1,5 @@ -- `.hash()` through a Hash bound runs on a range. -fn h(v: a) -> Int where a: Hash { v.hash() } +fn h(v: a) -> Int where a: Hash { Hash.hash(v) } fn main() { let r = 1..5 println(h(r) == h(r)) diff --git a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_some_int.silt b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_some_int.silt index 52d4700dd..32231beca 100644 --- a/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_some_int.silt +++ b/tests/golden/typecheck/traits/vm_trait_dispatch_runtime__hash_on_some_int.silt @@ -1,3 +1,3 @@ -- `.hash()` through a Hash bound runs on an Option variant. -fn h(v: a) -> Int where a: Hash { v.hash() } +fn h(v: a) -> Int where a: Hash { Hash.hash(v) } fn main() { println(h(Some(1)) == h(Some(1))) } diff --git a/tests/golden/typecheck/types/type_value__no_trait_and_no_message_names_its_internal_type.silt b/tests/golden/typecheck/types/type_value__no_trait_and_no_message_names_its_internal_type.silt index e71aa8957..222affa66 100644 --- a/tests/golden/typecheck/types/type_value__no_trait_and_no_message_names_its_internal_type.silt +++ b/tests/golden/typecheck/types/type_value__no_trait_and_no_message_names_its_internal_type.silt @@ -25,11 +25,11 @@ fn less(x: a) -> Bool where a: Compare { } fn hashed(x: a) -> Int where a: Hash { - x.hash() + Hash.hash(x) } fn told(x: a) -> String where a: Show { - x.show() + Show.show(x) } fn named(type a) -> String { diff --git a/tests/golden/typecheck/unused/unused_value__a_method_of_a_bounded_receiver.silt b/tests/golden/typecheck/unused/unused_value__a_method_of_a_bounded_receiver.silt index 166bfc49f..361a24552 100644 --- a/tests/golden/typecheck/unused/unused_value__a_method_of_a_bounded_receiver.silt +++ b/tests/golden/typecheck/unused/unused_value__a_method_of_a_bounded_receiver.silt @@ -14,7 +14,7 @@ trait Greet for Int { } fn hello(x) { - x.greet() + Greet.greet(x) 2 } diff --git a/tests/golden/typecheck/unused/unused_value__a_method_of_a_bounded_receiver.stderr b/tests/golden/typecheck/unused/unused_value__a_method_of_a_bounded_receiver.stderr index ce2242980..8a1b879ab 100644 --- a/tests/golden/typecheck/unused/unused_value__a_method_of_a_bounded_receiver.stderr +++ b/tests/golden/typecheck/unused/unused_value__a_method_of_a_bounded_receiver.stderr @@ -1,5 +1,5 @@ error[type]: this `String` value is unused; write `let _ = ...` to discard it --> unused_value__a_method_of_a_bounded_receiver.silt:17:3 | - 17 | x.greet() - | ^^^^^^^^^ this `String` value is unused; write `let _ = ...` to discard it + 17 | Greet.greet(x) + | ^^^^^^^^^^^^^^ this `String` value is unused; write `let _ = ...` to discard it diff --git a/tests/golden/typecheck/unused/unused_value__an_associated_type_of_an_unknown_type.silt b/tests/golden/typecheck/unused/unused_value__an_associated_type_of_an_unknown_type.silt index a07309c4b..3afb126ed 100644 --- a/tests/golden/typecheck/unused/unused_value__an_associated_type_of_an_unknown_type.silt +++ b/tests/golden/typecheck/unused/unused_value__an_associated_type_of_an_unknown_type.silt @@ -9,18 +9,18 @@ trait Source { type Item fn next(self) -> Self::Item fn skip(self) -> String { - self.next() + Source.next(self) "skipped" } } fn drain(s: a) -> String where a: Source { - s.next() + Source.next(s) "drained" } fn drain_inferred(s) { - s.next() + Source.next(s) "drained" } @@ -32,7 +32,7 @@ trait Source for Int { } fn main() { - println(1.skip()) + println(Source.skip(1)) println(drain(1)) println(drain_inferred(1)) } diff --git a/tests/golden/typecheck/unused/unused_value__an_associated_type_of_an_unknown_type.stderr b/tests/golden/typecheck/unused/unused_value__an_associated_type_of_an_unknown_type.stderr index ca12bab6b..b348caede 100644 --- a/tests/golden/typecheck/unused/unused_value__an_associated_type_of_an_unknown_type.stderr +++ b/tests/golden/typecheck/unused/unused_value__an_associated_type_of_an_unknown_type.stderr @@ -1,17 +1,17 @@ error[type]: this `::Item` value is unused; write `let _ = ...` to discard it --> unused_value__an_associated_type_of_an_unknown_type.silt:12:5 | - 12 | self.next() - | ^^^^^^^^^^^ this `::Item` value is unused; write `let _ = ...` to discard it + 12 | Source.next(self) + | ^^^^^^^^^^^^^^^^^ this `::Item` value is unused; write `let _ = ...` to discard it error[type]: this `::Item` value is unused; write `let _ = ...` to discard it --> unused_value__an_associated_type_of_an_unknown_type.silt:18:3 | - 18 | s.next() - | ^^^^^^^^ this `::Item` value is unused; write `let _ = ...` to discard it + 18 | Source.next(s) + | ^^^^^^^^^^^^^^ this `::Item` value is unused; write `let _ = ...` to discard it error[type]: this value is unused; write `let _ = ...` to discard it --> unused_value__an_associated_type_of_an_unknown_type.silt:23:3 | - 23 | s.next() - | ^^^^^^^^ this value is unused; write `let _ = ...` to discard it + 23 | Source.next(s) + | ^^^^^^^^^^^^^^ this value is unused; write `let _ = ...` to discard it diff --git a/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_a_value.silt b/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_a_value.silt index 05678e0d7..3c4f410d8 100644 --- a/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_a_value.silt +++ b/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_a_value.silt @@ -31,7 +31,7 @@ trait Source for Counter { } fn main() { - Disk { name: "a" }.next() - Counter { n: 1 }.next() + Source.next(Disk { name: "a" }) + Source.next(Counter { n: 1 }) println("done") } diff --git a/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_a_value.stderr b/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_a_value.stderr index b02922f0c..8b378ad65 100644 --- a/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_a_value.stderr +++ b/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_a_value.stderr @@ -1,11 +1,11 @@ error[type]: this `Result` is unused: an error in it would go unseen; handle it, return it with `?`, or write `let _ = ...` --> unused_value__an_associated_type_that_is_a_value.silt:34:3 | - 34 | Disk { name: "a" }.next() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ this `Result` is unused: an error in it would go unseen; handle it, return it with `?`, or write `let _ = ...` + 34 | Source.next(Disk { name: "a" }) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this `Result` is unused: an error in it would go unseen; handle it, return it with `?`, or write `let _ = ...` error[type]: this `Int` value is unused; write `let _ = ...` to discard it --> unused_value__an_associated_type_that_is_a_value.silt:35:3 | - 35 | Counter { n: 1 }.next() - | ^^^^^^^^^^^^^^^^^^^^^^^ this `Int` value is unused; write `let _ = ...` to discard it + 35 | Source.next(Counter { n: 1 }) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this `Int` value is unused; write `let _ = ...` to discard it diff --git a/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_unit.silt b/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_unit.silt index 974b6a581..759dc82b4 100644 --- a/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_unit.silt +++ b/tests/golden/typecheck/unused/unused_value__an_associated_type_that_is_unit.silt @@ -19,7 +19,7 @@ trait Sink for Printer { fn main() { let p = Printer { name: "p" } - p.emit() - let u: () = p.emit() + Sink.emit(p) + let u: () = Sink.emit(p) println("done {u}") } diff --git a/tests/golden/typecheck/unused/unused_value__in_trait_methods.silt b/tests/golden/typecheck/unused/unused_value__in_trait_methods.silt index ea19a54b5..4fb3b45ac 100644 --- a/tests/golden/typecheck/unused/unused_value__in_trait_methods.silt +++ b/tests/golden/typecheck/unused/unused_value__in_trait_methods.silt @@ -5,8 +5,8 @@ trait Describe { fn name(self) -> String fn twice(self) -> String { - self.name() - "{self.name()} {self.name()}" + Describe.name(self) + "{Describe.name(self)} {Describe.name(self)}" } } @@ -18,5 +18,5 @@ trait Describe for Int { } fn main() { - println(3.twice()) + println(Describe.twice(3)) } diff --git a/tests/golden/typecheck/unused/unused_value__in_trait_methods.stderr b/tests/golden/typecheck/unused/unused_value__in_trait_methods.stderr index 2a11faa85..aa9854921 100644 --- a/tests/golden/typecheck/unused/unused_value__in_trait_methods.stderr +++ b/tests/golden/typecheck/unused/unused_value__in_trait_methods.stderr @@ -1,8 +1,8 @@ error[type]: this `String` value is unused; write `let _ = ...` to discard it --> unused_value__in_trait_methods.silt:8:5 | - 8 | self.name() - | ^^^^^^^^^^^ this `String` value is unused; write `let _ = ...` to discard it + 8 | Describe.name(self) + | ^^^^^^^^^^^^^^^^^^^ this `String` value is unused; write `let _ = ...` to discard it error[type]: this `Int` value is unused; write `let _ = ...` to discard it --> unused_value__in_trait_methods.silt:15:5 diff --git a/tests/golden/typecheck/wave1/wave1_typechecker__guard_correct_impls_alias_and_range.silt b/tests/golden/typecheck/wave1/wave1_typechecker__guard_correct_impls_alias_and_range.silt index 2b8a17b97..c7077e8cb 100644 --- a/tests/golden/typecheck/wave1/wave1_typechecker__guard_correct_impls_alias_and_range.silt +++ b/tests/golden/typecheck/wave1/wave1_typechecker__guard_correct_impls_alias_and_range.silt @@ -10,8 +10,8 @@ trait Bar for List(a) { fn bar(self) -> Int { 8 } } fn main() { - println([1, 2].foo()) - println((1..3).foo()) - println((1..3).bar()) - println([4, 5].bar()) + println(Foo.foo([1, 2])) + println(Foo.foo(1..3)) + println(Bar.bar(1..3)) + println(Bar.bar([4, 5])) } diff --git a/tests/golden/typecheck/wave1/wave1_typechecker__guard_impl_for_alias_no_narrowing.silt b/tests/golden/typecheck/wave1/wave1_typechecker__guard_impl_for_alias_no_narrowing.silt index fa239157b..fbd3992da 100644 --- a/tests/golden/typecheck/wave1/wave1_typechecker__guard_impl_for_alias_no_narrowing.silt +++ b/tests/golden/typecheck/wave1/wave1_typechecker__guard_impl_for_alias_no_narrowing.silt @@ -8,4 +8,4 @@ type Ints = List(Int) trait Foo for Ints { fn foo(self) -> Int { "not an int" } } -fn main() -> () { println([1, 2].foo()) } +fn main() -> () { println(Foo.foo([1, 2])) } diff --git a/tests/golden/typecheck/wave1/wave1_typechecker__guard_impl_for_list_body_error.silt b/tests/golden/typecheck/wave1/wave1_typechecker__guard_impl_for_list_body_error.silt index 14c39020e..50adb0269 100644 --- a/tests/golden/typecheck/wave1/wave1_typechecker__guard_impl_for_list_body_error.silt +++ b/tests/golden/typecheck/wave1/wave1_typechecker__guard_impl_for_list_body_error.silt @@ -7,4 +7,4 @@ trait Foo { fn foo(self) -> Int } trait Foo for List(a) { fn foo(self) -> Int { "not an int" } } -fn main() { println([1, 2].foo()) } +fn main() { println(Foo.foo([1, 2])) } diff --git a/tests/golden/typecheck/wave1/wave1_typechecker__impl_error_with_other_errors.silt b/tests/golden/typecheck/wave1/wave1_typechecker__impl_error_with_other_errors.silt index d3c88f06d..ed81f5a4a 100644 --- a/tests/golden/typecheck/wave1/wave1_typechecker__impl_error_with_other_errors.silt +++ b/tests/golden/typecheck/wave1/wave1_typechecker__impl_error_with_other_errors.silt @@ -12,5 +12,5 @@ trait Foo for Ints { fn helper(x) { x + 1 } fn main() { let n: String = helper(1) - println([1, 2].foo()) + println(Foo.foo([1, 2])) } diff --git a/tests/golden/typecheck/wave1/wave1_typechecker__impl_for_alias_body_error.silt b/tests/golden/typecheck/wave1/wave1_typechecker__impl_for_alias_body_error.silt index 42ea26da7..ec0bc976b 100644 --- a/tests/golden/typecheck/wave1/wave1_typechecker__impl_for_alias_body_error.silt +++ b/tests/golden/typecheck/wave1/wave1_typechecker__impl_for_alias_body_error.silt @@ -8,4 +8,4 @@ type Ints = List(Int) trait Foo for Ints { fn foo(self) -> Int { "not an int" } } -fn main() { println([1, 2].foo()) } +fn main() { println(Foo.foo([1, 2])) } diff --git a/tests/golden/typecheck/wave1/wave1_typechecker__impl_for_alias_body_error_run.silt b/tests/golden/typecheck/wave1/wave1_typechecker__impl_for_alias_body_error_run.silt index e30342af0..4a831358d 100644 --- a/tests/golden/typecheck/wave1/wave1_typechecker__impl_for_alias_body_error_run.silt +++ b/tests/golden/typecheck/wave1/wave1_typechecker__impl_for_alias_body_error_run.silt @@ -7,4 +7,4 @@ type Ints = List(Int) trait Foo for Ints { fn foo(self) -> Int { "not an int" } } -fn main() { println([1, 2].foo()) } +fn main() { println(Foo.foo([1, 2])) } diff --git a/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__alias_fn_value_rejected.silt b/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__alias_fn_value_rejected.silt index f44815758..6d4e98313 100644 --- a/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__alias_fn_value_rejected.silt +++ b/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__alias_fn_value_rejected.silt @@ -13,7 +13,7 @@ trait Keys for Named(a) where a: Display { fn k(self) -> Int { map.length(self) } } -fn go(x: b) -> Int where b: Keys { x.k() } +fn go(x: b) -> Int where b: Keys { Keys.k(x) } fn main() { println(go(#{ "a": { x -> x + 1 } })) diff --git a/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__alias_value_slot_accepts.silt b/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__alias_value_slot_accepts.silt index 29f7a9bdf..66c62fdbe 100644 --- a/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__alias_value_slot_accepts.silt +++ b/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__alias_value_slot_accepts.silt @@ -12,7 +12,7 @@ trait Keys for Named(a) where a: Marked { fn k(self) -> Int { map.length(self) } } -fn go(x: b) -> Int where b: Keys { x.k() } +fn go(x: b) -> Int where b: Keys { Keys.k(x) } fn main() { println(go(#{ "a": 1 })) diff --git a/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__direct_map_key_bound_rejected.silt b/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__direct_map_key_bound_rejected.silt index 4de120120..75cf70380 100644 --- a/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__direct_map_key_bound_rejected.silt +++ b/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__direct_map_key_bound_rejected.silt @@ -11,7 +11,7 @@ trait Keyed for Map(k, v) where k: Marked { fn total(self) -> Int { map.length(self) } } -fn go(x: b) -> Int where b: Keyed { x.total() } +fn go(x: b) -> Int where b: Keyed { Keyed.total(x) } fn main() { println(go(#{ "a": 7 })) diff --git a/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__direct_map_value_bound.silt b/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__direct_map_value_bound.silt index 9b09cff8b..8cb4a8bce 100644 --- a/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__direct_map_value_bound.silt +++ b/tests/golden/typecheck/where_clauses/alias_impl_where_clause_slot__direct_map_value_bound.silt @@ -9,7 +9,7 @@ trait Vals for Map(k, v) where v: Marked { fn total(self) -> Int { map.length(self) } } -fn go(x: b) -> Int where b: Vals { x.total() } +fn go(x: b) -> Int where b: Vals { Vals.total(x) } fn main() { println(go(#{ "a": 7 })) diff --git a/tests/golden/typecheck/where_clauses/impl_header__bound_on_a_nested_part.silt b/tests/golden/typecheck/where_clauses/impl_header__bound_on_a_nested_part.silt index 03c1c0f7e..5bccc0772 100644 --- a/tests/golden/typecheck/where_clauses/impl_header__bound_on_a_nested_part.silt +++ b/tests/golden/typecheck/where_clauses/impl_header__bound_on_a_nested_part.silt @@ -7,7 +7,7 @@ trait Marked { fn mark(self) -> String } trait Marked for Int { fn mark(self) -> String { "int" } } type Named(a) = Map(String, List(a)) trait Marked for Named(a) where a: Marked { fn mark(self) -> String { "named" } } -fn need(x: t) -> String where t: Marked { x.mark() } +fn need(x: t) -> String where t: Marked { Marked.mark(x) } fn main() { println(need(#{ "a": [1] })) println(need(#{ "a": ["s"] })) diff --git a/tests/golden/typecheck/where_clauses/impl_header_sub_goal__closure_let.silt b/tests/golden/typecheck/where_clauses/impl_header_sub_goal__closure_let.silt index 1ac25447c..6eeaf9999 100644 --- a/tests/golden/typecheck/where_clauses/impl_header_sub_goal__closure_let.silt +++ b/tests/golden/typecheck/where_clauses/impl_header_sub_goal__closure_let.silt @@ -6,8 +6,8 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } type Box(a) { Box(a) } -trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { Box(i) -> i.greet() } } } -fn hello(x: a) -> String where a: Greet { x.greet() } +trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { Box(i) -> Greet.greet(i) } } } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { let g = { x -> hello(Box(x)) } println(g(3)) diff --git a/tests/golden/typecheck/where_clauses/impl_header_sub_goal__decided_later.silt b/tests/golden/typecheck/where_clauses/impl_header_sub_goal__decided_later.silt index 7bec9d451..e77b8cb84 100644 --- a/tests/golden/typecheck/where_clauses/impl_header_sub_goal__decided_later.silt +++ b/tests/golden/typecheck/where_clauses/impl_header_sub_goal__decided_later.silt @@ -6,16 +6,16 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } type Box(a) { Box(a) } -trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { Box(i) -> i.greet() } } } +trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { Box(i) -> Greet.greet(i) } } } trait Greet for List(a) where a: Greet { fn greet(self) -> String { match self { - [x, ..r] -> x.greet() + [x, ..r] -> Greet.greet(x) _ -> "e" } } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } import channel fn main() { let ch = channel.new(2) diff --git a/tests/golden/typecheck/where_clauses/impl_header_sub_goal__nothing_decides_the_type.silt b/tests/golden/typecheck/where_clauses/impl_header_sub_goal__nothing_decides_the_type.silt index 594171b07..3703957d3 100644 --- a/tests/golden/typecheck/where_clauses/impl_header_sub_goal__nothing_decides_the_type.silt +++ b/tests/golden/typecheck/where_clauses/impl_header_sub_goal__nothing_decides_the_type.silt @@ -6,7 +6,7 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } type Box(a) { Box(a) } -trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { Box(i) -> i.greet() } } } -fn hello(x: a) -> String where a: Greet { x.greet() } +trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { Box(i) -> Greet.greet(i) } } } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } import list fn main() { println(list.length(list.map([], hello))) } diff --git a/tests/golden/typecheck/where_clauses/impl_header_sub_goal__unannotated_fn.silt b/tests/golden/typecheck/where_clauses/impl_header_sub_goal__unannotated_fn.silt index ac7ad4314..6ece53acb 100644 --- a/tests/golden/typecheck/where_clauses/impl_header_sub_goal__unannotated_fn.silt +++ b/tests/golden/typecheck/where_clauses/impl_header_sub_goal__unannotated_fn.silt @@ -7,7 +7,7 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } type Box(a) { Box(a) } -trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { Box(i) -> i.greet() } } } -fn hello(x: a) -> String where a: Greet { x.greet() } +trait Greet for Box(a) where a: Greet { fn greet(self) -> String { match self { Box(i) -> Greet.greet(i) } } } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn w(x) { hello(Box(x)) } fn main() { println(w("s")) } diff --git a/tests/golden/typecheck/where_clauses/let_annotation_variable__cannot_have_a_bound.silt b/tests/golden/typecheck/where_clauses/let_annotation_variable__cannot_have_a_bound.silt index 55ba87c6e..44906c1aa 100644 --- a/tests/golden/typecheck/where_clauses/let_annotation_variable__cannot_have_a_bound.silt +++ b/tests/golden/typecheck/where_clauses/let_annotation_variable__cannot_have_a_bound.silt @@ -5,7 +5,7 @@ -- stderr-not-contains: enclosing function trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } -fn hello(x: a) -> String where a: Greet { x.greet() } +fn hello(x: a) -> String where a: Greet { Greet.greet(x) } fn main() { let f: Fn(a) -> String = hello println(f(3)) diff --git a/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__generic_impl_any_elements.silt b/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__generic_impl_any_elements.silt index f5ff06189..05608484b 100644 --- a/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__generic_impl_any_elements.silt +++ b/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__generic_impl_any_elements.silt @@ -1,5 +1,5 @@ import list trait Total { fn total(self) -> Int } trait Total for List(a) { fn total(self) -> Int { list.length(self) } } -fn sum_it(x: a) -> Int where a: Total { x.total() } +fn sum_it(x: a) -> Int where a: Total { Total.total(x) } fn main() { println(sum_it(["a", "b", "c"])) } diff --git a/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__named_rejects_key_type.silt b/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__named_rejects_key_type.silt index 0e2aa6664..dff385b38 100644 --- a/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__named_rejects_key_type.silt +++ b/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__named_rejects_key_type.silt @@ -5,5 +5,5 @@ import map type Named(a) = Map(String, a) trait Keys { fn keys_count(self) -> Int } trait Keys for Named(a) { fn keys_count(self) -> Int { map.length(self) } } -fn count_it(x: b) -> Int where b: Keys { x.keys_count() } +fn count_it(x: b) -> Int where b: Keys { Keys.keys_count(x) } fn main() { println(count_it(#{ 1: true, 2: false })) } diff --git a/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__named_runs_matching_key.silt b/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__named_runs_matching_key.silt index 8fb417724..6a171ed38 100644 --- a/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__named_runs_matching_key.silt +++ b/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__named_runs_matching_key.silt @@ -2,5 +2,5 @@ import map type Named(a) = Map(String, a) trait Keys { fn keys_count(self) -> Int } trait Keys for Named(a) { fn keys_count(self) -> Int { map.length(self) } } -fn count_it(x: b) -> Int where b: Keys { x.keys_count() } +fn count_it(x: b) -> Int where b: Keys { Keys.keys_count(x) } fn main() { println(count_it(#{ "a": 1, "b": 2 })) } diff --git a/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__rejects_mismatched_elements.silt b/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__rejects_mismatched_elements.silt index 7a9f9a568..ae07f0138 100644 --- a/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__rejects_mismatched_elements.silt +++ b/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__rejects_mismatched_elements.silt @@ -9,5 +9,5 @@ import list type Bytes2 = List(Int) trait Total { fn total(self) -> Int } trait Total for Bytes2 { fn total(self) -> Int { list.fold(self, 0, { acc, x -> acc + x }) } } -fn sum_it(x: a) -> Int where a: Total { x.total() } +fn sum_it(x: a) -> Int where a: Total { Total.total(x) } fn main() { println(sum_it(["a", "b"])) } diff --git a/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__runs_matching_elements.silt b/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__runs_matching_elements.silt index da8b4e574..b8e64e634 100644 --- a/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__runs_matching_elements.silt +++ b/tests/golden/typecheck/where_clauses/round102_alias_impl_self_type_args_where_bound__runs_matching_elements.silt @@ -2,7 +2,7 @@ import list type Bytes2 = List(Int) trait Total { fn total(self) -> Int } trait Total for Bytes2 { fn total(self) -> Int { list.fold(self, 0, { acc, x -> acc + x }) } } -fn sum_it(x: a) -> Int where a: Total { x.total() } +fn sum_it(x: a) -> Int where a: Total { Total.total(x) } fn main() { let s = [1, 2] |> sum_it println(s) diff --git a/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__bare_tuple_impl_any_tuple.silt b/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__bare_tuple_impl_any_tuple.silt index beb0ab8d1..ce9ca5ba5 100644 --- a/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__bare_tuple_impl_any_tuple.silt +++ b/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__bare_tuple_impl_any_tuple.silt @@ -1,4 +1,4 @@ trait Tag { fn tag(self) -> String } trait Tag for Tuple { fn tag(self) -> String { "tuple" } } -fn tag_it(x: a) -> String where a: Tag { x.tag() } +fn tag_it(x: a) -> String where a: Tag { Tag.tag(x) } fn main() { println(tag_it((1, "x", true))) } diff --git a/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__fn_rejects_mismatched.silt b/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__fn_rejects_mismatched.silt index 0a0af1d13..3551fed22 100644 --- a/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__fn_rejects_mismatched.silt +++ b/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__fn_rejects_mismatched.silt @@ -6,5 +6,5 @@ type IntOp = Fn(Int) -> Int trait Apply1 { fn app(self) -> Int } trait Apply1 for IntOp { fn app(self) -> Int { self(41) + 1 } } -fn go(x: a) -> Int where a: Apply1 { x.app() } +fn go(x: a) -> Int where a: Apply1 { Apply1.app(x) } fn main() { println(go({ s: String -> "{s}!" })) } diff --git a/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__fn_runs_matching.silt b/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__fn_runs_matching.silt index d69fca873..9f6684b66 100644 --- a/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__fn_runs_matching.silt +++ b/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__fn_runs_matching.silt @@ -1,5 +1,5 @@ type IntOp = Fn(Int) -> Int trait Apply1 { fn app(self) -> Int } trait Apply1 for IntOp { fn app(self) -> Int { self(41) + 1 } } -fn go(x: a) -> Int where a: Apply1 { x.app() } +fn go(x: a) -> Int where a: Apply1 { Apply1.app(x) } fn main() { println(go({ x -> x + 1 })) } diff --git a/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__tuple_rejects_mismatched.silt b/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__tuple_rejects_mismatched.silt index cc36084e0..a77113932 100644 --- a/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__tuple_rejects_mismatched.silt +++ b/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__tuple_rejects_mismatched.silt @@ -11,5 +11,5 @@ trait Total for P2 { x + y } } -fn sum_it(x: a) -> Int where a: Total { x.total() } +fn sum_it(x: a) -> Int where a: Total { Total.total(x) } fn main() { println(sum_it(("a", "b"))) } diff --git a/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__tuple_runs_matching.silt b/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__tuple_runs_matching.silt index 250dc9fe3..c92517c88 100644 --- a/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__tuple_runs_matching.silt +++ b/tests/golden/typecheck/where_clauses/round103_tuple_fn_alias_where_bound__tuple_runs_matching.silt @@ -6,5 +6,5 @@ trait Total for P2 { x + y } } -fn sum_it(x: a) -> Int where a: Total { x.total() } +fn sum_it(x: a) -> Int where a: Total { Total.total(x) } fn main() { println(sum_it((1, 2))) } diff --git a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__linear_two_param_mixed_slots.silt b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__linear_two_param_mixed_slots.silt index e0f76af95..14c3cb30b 100644 --- a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__linear_two_param_mixed_slots.silt +++ b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__linear_two_param_mixed_slots.silt @@ -6,5 +6,5 @@ trait First for Two(a, b) where a: Display { "{x}" } } -fn head_of(x: p) -> String where p: First { x.first_str() } +fn head_of(x: p) -> String where p: First { First.first_str(x) } fn main() { println(head_of((7, "seven"))) } diff --git a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_rejects_int_fn.silt b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_rejects_int_fn.silt index 0a39315bb..a1ef74874 100644 --- a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_rejects_int_fn.silt +++ b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_rejects_int_fn.silt @@ -10,7 +10,7 @@ trait Show2 for Pair(a) where a: Display { "{x} and {y}" } } -fn describe(x: p) -> String where p: Show2 { x.show2() } +fn describe(x: p) -> String where p: Show2 { Show2.show2(x) } fn main() { let f = { n -> n + 1 } println(describe((1, f))) diff --git a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_rejects_int_string.silt b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_rejects_int_string.silt index 6920ac53e..913c45cf3 100644 --- a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_rejects_int_string.silt +++ b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_rejects_int_string.silt @@ -10,5 +10,5 @@ trait Show2 for Pair(a) where a: Display { "{x} and {y}" } } -fn describe(x: p) -> String where p: Show2 { x.show2() } +fn describe(x: p) -> String where p: Show2 { Show2.show2(x) } fn main() { println(describe((1, "z"))) } diff --git a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_runs_matching.silt b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_runs_matching.silt index 9c70d73a7..d19b95af7 100644 --- a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_runs_matching.silt +++ b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__pair_runs_matching.silt @@ -6,5 +6,5 @@ trait Show2 for Pair(a) where a: Display { "{x} and {y}" } } -fn describe(x: p) -> String where p: Show2 { x.show2() } +fn describe(x: p) -> String where p: Show2 { Show2.show2(x) } fn main() { println(describe((1, 2))) } diff --git a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__square_map_rejects_mismatch.silt b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__square_map_rejects_mismatch.silt index ae69d642d..a931da365 100644 --- a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__square_map_rejects_mismatch.silt +++ b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__square_map_rejects_mismatch.silt @@ -4,5 +4,5 @@ type Square(a) = Map(a, a) trait Tag { fn tag(self) -> String } trait Tag for Square(a) { fn tag(self) -> String { "square" } } -fn tag_it(x: t) -> String where t: Tag { x.tag() } +fn tag_it(x: t) -> String where t: Tag { Tag.tag(x) } fn main() { println(tag_it(#{ "k": 1 })) } diff --git a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__square_map_runs_matching.silt b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__square_map_runs_matching.silt index 023e5bae9..21e5c3637 100644 --- a/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__square_map_runs_matching.silt +++ b/tests/golden/typecheck/where_clauses/round104_nonlinear_impl_self_type_linkage__square_map_runs_matching.silt @@ -1,5 +1,5 @@ type Square(a) = Map(a, a) trait Tag { fn tag(self) -> String } trait Tag for Square(a) { fn tag(self) -> String { "square" } } -fn tag_it(x: t) -> String where t: Tag { x.tag() } +fn tag_it(x: t) -> String where t: Tag { Tag.tag(x) } fn main() { println(tag_it(#{ 1: 2 })) } diff --git a/tests/golden/typecheck/where_clauses/trait_args_verification__matching_args_ok.silt b/tests/golden/typecheck/where_clauses/trait_args_verification__matching_args_ok.silt index 045fd8cff..498c754c3 100644 --- a/tests/golden/typecheck/where_clauses/trait_args_verification__matching_args_ok.silt +++ b/tests/golden/typecheck/where_clauses/trait_args_verification__matching_args_ok.silt @@ -1,4 +1,4 @@ trait TryInto(b) { fn try_into(self) -> Result(b, String) } trait TryInto(Float) for String { fn try_into(self) { Ok(1.5) } } -fn convert(s: a) -> Result(Float, String) where a: TryInto(Float) { s.try_into() } +fn convert(s: a) -> Result(Float, String) where a: TryInto(Float) { TryInto.try_into(s) } fn main() { println(convert("hi")) } diff --git a/tests/golden/typecheck/where_clauses/trait_args_verification__mismatched_args_rejected.silt b/tests/golden/typecheck/where_clauses/trait_args_verification__mismatched_args_rejected.silt index 043d3b2c6..64b70376d 100644 --- a/tests/golden/typecheck/where_clauses/trait_args_verification__mismatched_args_rejected.silt +++ b/tests/golden/typecheck/where_clauses/trait_args_verification__mismatched_args_rejected.silt @@ -4,5 +4,5 @@ -- stderr-contains: TryInto(Int) trait TryInto(b) { fn try_into(self) -> Result(b, String) } trait TryInto(Float) for String { fn try_into(self) { Ok(1.5) } } -fn convert(s: a) -> Result(Int, String) where a: TryInto(Int) { s.try_into() } +fn convert(s: a) -> Result(Int, String) where a: TryInto(Int) { TryInto.try_into(s) } fn main() { println(convert("hi")) } diff --git a/tests/golden/typecheck/where_clauses/trait_args_verification__parameterless_where_ok.silt b/tests/golden/typecheck/where_clauses/trait_args_verification__parameterless_where_ok.silt index c00594c89..0f6f20f0d 100644 --- a/tests/golden/typecheck/where_clauses/trait_args_verification__parameterless_where_ok.silt +++ b/tests/golden/typecheck/where_clauses/trait_args_verification__parameterless_where_ok.silt @@ -1,4 +1,4 @@ trait MyDisplay { fn my_display(self) -> String } trait MyDisplay for Int { fn my_display(self) -> String { "int" } } -fn show(x: a) -> String where a: MyDisplay { x.my_display() } +fn show(x: a) -> String where a: MyDisplay { MyDisplay.my_display(x) } fn main() { println(show(42)) } diff --git a/tests/golden/typecheck/where_clauses/trait_args_where_clause_runtime__impl_level_where_args.silt b/tests/golden/typecheck/where_clauses/trait_args_where_clause_runtime__impl_level_where_args.silt index e9147876b..d777fc391 100644 --- a/tests/golden/typecheck/where_clauses/trait_args_where_clause_runtime__impl_level_where_args.silt +++ b/tests/golden/typecheck/where_clauses/trait_args_where_clause_runtime__impl_level_where_args.silt @@ -11,14 +11,14 @@ trait UseIt for List(a) where a: Conv(Int) { match self { [] -> 0 [x, ..rest] -> { - let n: Int = x.conv() - n + rest.use_it() + let n: Int = Conv.conv(x) + n + UseIt.use_it(rest) } } } } fn main() { let xs: List(Int) = [1, 2, 3] - let r: Int = xs.use_it() + let r: Int = UseIt.use_it(xs) println(r) } diff --git a/tests/golden/typecheck/where_clauses/trait_args_where_clause_runtime__method_signature_mismatch_span.silt b/tests/golden/typecheck/where_clauses/trait_args_where_clause_runtime__method_signature_mismatch_span.silt index b698f8c5d..a89ea3877 100644 --- a/tests/golden/typecheck/where_clauses/trait_args_where_clause_runtime__method_signature_mismatch_span.silt +++ b/tests/golden/typecheck/where_clauses/trait_args_where_clause_runtime__method_signature_mismatch_span.silt @@ -9,4 +9,4 @@ trait Foo(a) { fn bar(self: a) -> Int } trait Foo(String) for String { fn bar(self) -> String { "hello" } } -fn main() { println("x".bar()) } +fn main() { println(Foo.bar("x")) } diff --git a/tests/golden/typecheck/where_clauses/trait_argument__decided_by_the_impl.silt b/tests/golden/typecheck/where_clauses/trait_argument__decided_by_the_impl.silt index 42eae352a..80e775004 100644 --- a/tests/golden/typecheck/where_clauses/trait_argument__decided_by_the_impl.silt +++ b/tests/golden/typecheck/where_clauses/trait_argument__decided_by_the_impl.silt @@ -6,6 +6,6 @@ -- a function of a String. trait Conv(to) { fn conv(self) -> to } trait Conv(String) for Int { fn conv(self) -> String { "an int" } } -fn s(x: a, y: b) -> b where a: Conv(b) { x.conv() } +fn s(x: a, y: b) -> b where a: Conv(b) { Conv.conv(x) } fn w(y) { s(3, y) } fn main() { println(w(1) + 1) } diff --git a/tests/golden/typecheck/where_clauses/trait_argument__decided_by_the_impl_accepts.silt b/tests/golden/typecheck/where_clauses/trait_argument__decided_by_the_impl_accepts.silt index 756a8f545..013a56fe5 100644 --- a/tests/golden/typecheck/where_clauses/trait_argument__decided_by_the_impl_accepts.silt +++ b/tests/golden/typecheck/where_clauses/trait_argument__decided_by_the_impl_accepts.silt @@ -1,7 +1,7 @@ -- The same, used at the type the impl says. trait Conv(to) { fn conv(self) -> to } trait Conv(String) for Int { fn conv(self) -> String { "an int" } } -fn s(x: a, y: b) -> b where a: Conv(b) { x.conv() } +fn s(x: a, y: b) -> b where a: Conv(b) { Conv.conv(x) } fn w(y) { s(3, y) } fn main() { let g = { y -> s(3, y) } diff --git a/tests/golden/typecheck/where_clauses/trait_argument__rigid_bound_argument_differs.silt b/tests/golden/typecheck/where_clauses/trait_argument__rigid_bound_argument_differs.silt index 0ea976709..5c7c08fc6 100644 --- a/tests/golden/typecheck/where_clauses/trait_argument__rigid_bound_argument_differs.silt +++ b/tests/golden/typecheck/where_clauses/trait_argument__rigid_bound_argument_differs.silt @@ -4,6 +4,6 @@ -- A declared bound has its trait arguments: `a: Conv(String)` does not -- give `a: Conv(Int)`. trait Conv(to) { fn conv(self) -> to } -fn need_int(x: a) -> Int where a: Conv(Int) { x.conv() } +fn need_int(x: a) -> Int where a: Conv(Int) { Conv.conv(x) } fn f(x: a) -> Int where a: Conv(String) { need_int(x) } fn main() { println(1) } diff --git a/tests/golden/typecheck/where_clauses/trait_argument__sub_goal_with_argument.silt b/tests/golden/typecheck/where_clauses/trait_argument__sub_goal_with_argument.silt index 43eb4a935..de05a3056 100644 --- a/tests/golden/typecheck/where_clauses/trait_argument__sub_goal_with_argument.silt +++ b/tests/golden/typecheck/where_clauses/trait_argument__sub_goal_with_argument.silt @@ -5,8 +5,8 @@ -- is owed with its argument. trait Conv(to) { fn conv(self) -> to } trait Conv(String) for Int { fn conv(self) -> String { "an int" } } -fn s(x: a, y: b) -> b where a: Conv(b) { x.conv() } +fn s(x: a, y: b) -> b where a: Conv(b) { Conv.conv(x) } type Box(a) { Box(a) } -trait Conv(String) for Box(a) where a: Conv(String) { fn conv(self) -> String { match self { Box(i) -> i.conv() } } } +trait Conv(String) for Box(a) where a: Conv(String) { fn conv(self) -> String { match self { Box(i) -> Conv.conv(i) } } } fn w(y) { s(Box(y), "q") } fn main() { println(w(true)) } diff --git a/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt b/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt index c22f4655a..8d0d3c134 100644 --- a/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt +++ b/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt @@ -1,10 +1,12 @@ -- cmd: check -- exit: 1 --- Two bounds of one trait at different arguments are two bounds: a --- method both give is ambiguous (on a value and on a `type a`), whether --- its type names the trait's argument or not, with the bounds help; a --- function that needs one of the two is given it, and one that needs a --- third is told the two that are declared. +-- Two bounds of one trait at different arguments are two bounds: a call +-- through the trait whose type does not decide the argument is +-- ambiguous (`Conv.show`), one whose result type does is not +-- (`Conv.conv` returning String); a constructor on a `type a` both give +-- is ambiguous, with the bounds help; a function that needs one of the +-- two is given it, and one that needs a third is told the two that are +-- declared. trait Conv(b) { fn show(self) -> String fn conv(self) -> b @@ -15,11 +17,11 @@ trait Make(b) { } fn shown(x: a) -> String where a: Conv(Int), a: Conv(String) { - x.show() + Conv.show(x) } fn converted(x: a) -> String where a: Conv(Int) + Conv(String) { - x.conv() + Conv.conv(x) } fn made(type a) -> a where a: Make(Int), a: Make(String) { @@ -27,7 +29,7 @@ fn made(type a) -> a where a: Make(Int), a: Make(String) { } fn one(x: a) -> String where a: Conv(String) { - x.show() + Conv.show(x) } fn passes(x: a) -> String where a: Conv(Int), a: Conv(String) { @@ -35,7 +37,7 @@ fn passes(x: a) -> String where a: Conv(Int), a: Conv(String) { } fn other(x: a) -> String where a: Conv(Bool) { - x.show() + Conv.show(x) } fn wrong(x: a) -> String where a: Conv(Int), a: Conv(String) { diff --git a/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_method_both_give_is_ambiguous.stderr b/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_method_both_give_is_ambiguous.stderr index 0303288e1..09c66fcc6 100644 --- a/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_method_both_give_is_ambiguous.stderr +++ b/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_method_both_give_is_ambiguous.stderr @@ -1,26 +1,18 @@ -error[type]: ambiguous method 'show' on a value of type `a`: provided by bounds Conv(Int), Conv(String) - --> two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt:18:3 +error[type]: type variable `a` is declared to implement 'Conv(Int)' and 'Conv(String)', and which of them this use needs is not known + --> two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt:20:13 | - 18 | x.show() - | ^^^^^^ ambiguous method 'show' on a value of type `a`: provided by bounds Conv(Int), Conv(String) - = help: the bounds `Conv(Int)` and `Conv(String)` both give `show`: call it from a function bounded by only one of them - -error[type]: ambiguous method 'conv' on a value of type `a`: provided by bounds Conv(Int), Conv(String) - --> two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt:22:3 - | - 22 | x.conv() - | ^^^^^^ ambiguous method 'conv' on a value of type `a`: provided by bounds Conv(Int), Conv(String) - = help: the bounds `Conv(Int)` and `Conv(String)` both give `conv`: call it from a function bounded by only one of them + 20 | Conv.show(x) + | ^ type variable `a` is declared to implement 'Conv(Int)' and 'Conv(String)', and which of them this use needs is not known error[type]: ambiguous method 'make' on `type a`: provided by bounds Make(Int), Make(String) - --> two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt:26:3 + --> two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt:28:3 | - 26 | a.make() + 28 | a.make() | ^^^^^^ ambiguous method 'make' on `type a`: provided by bounds Make(Int), Make(String) = help: the bounds `Make(Int)` and `Make(String)` both give `make`: call it from a function bounded by only one of them error[type]: type variable `a` is declared to implement 'Conv(Int)' and 'Conv(String)', not 'Conv(Bool)' - --> two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt:42:9 + --> two_bounds_of_one_trait__a_method_both_give_is_ambiguous.silt:44:9 | - 42 | other(x) + 44 | other(x) | ^ type variable `a` is declared to implement 'Conv(Int)' and 'Conv(String)', not 'Conv(Bool)' diff --git a/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_use_waits_for_its_arguments.silt b/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_use_waits_for_its_arguments.silt index b5a71e5fb..a363050ca 100644 --- a/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_use_waits_for_its_arguments.silt +++ b/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__a_use_waits_for_its_arguments.silt @@ -12,7 +12,7 @@ type T { n: Int } trait Conv(b) for T { fn show(self) -> String { "T {self.n}" } } -fn gen2(x: a, y: List(c)) -> String where a: Conv(c) { x.show() } +fn gen2(x: a, y: List(c)) -> String where a: Conv(c) { Conv.show(x) } fn both(x: a, ys) -> String where a: Conv(Int), a: Conv(String) { let r = gen2(x, ys) let _ = [1] == ys diff --git a/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__the_help_names_the_bounds_as_written.silt b/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__the_help_names_the_bounds_as_written.silt index aec2369c3..311dd534a 100644 --- a/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__the_help_names_the_bounds_as_written.silt +++ b/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__the_help_names_the_bounds_as_written.silt @@ -1,8 +1,9 @@ -- cmd: check -- exit: 1 --- The help of a method two bounds give names the bounds as the `where` --- clause writes them: `Sub(Int)`, whose supertrait `Conv(Int)` gives the --- method, and `Conv(String)`; two bounds of a subtrait are named so too. +-- A call through a trait whose argument two bounds give differently is +-- ambiguous: `Sub(Int)` gives `Conv(Int)` through its supertrait, beside +-- `Conv(String)`, and two bounds of a subtrait give two too; a bound and +-- a subtrait's bound at one argument are one. trait Conv(b) { fn show(self) -> String } @@ -12,15 +13,15 @@ trait Sub(b): Conv(b) { } fn mixed(x: a) -> String where a: Sub(Int), a: Conv(String) { - x.show() + Conv.show(x) } fn subs(x: a) -> String where a: Sub(Int), a: Sub(String) { - x.show() + Conv.show(x) } fn same(x: a) -> String where a: Sub(Int), a: Conv(Int) { - x.show() + Conv.show(x) } fn main() { diff --git a/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__the_help_names_the_bounds_as_written.stderr b/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__the_help_names_the_bounds_as_written.stderr index 3592b6b28..4cf6df55e 100644 --- a/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__the_help_names_the_bounds_as_written.stderr +++ b/tests/golden/typecheck/where_clauses/two_bounds_of_one_trait__the_help_names_the_bounds_as_written.stderr @@ -1,13 +1,11 @@ -error[type]: ambiguous method 'show' on a value of type `a`: provided by bounds Conv(Int), Conv(String) - --> two_bounds_of_one_trait__the_help_names_the_bounds_as_written.silt:15:3 +error[type]: type variable `a` is declared to implement 'Conv(Int)' and 'Conv(String)', and which of them this use needs is not known + --> two_bounds_of_one_trait__the_help_names_the_bounds_as_written.silt:16:13 | - 15 | x.show() - | ^^^^^^ ambiguous method 'show' on a value of type `a`: provided by bounds Conv(Int), Conv(String) - = help: the bounds `Conv(String)` and `Sub(Int)` both give `show`: call it from a function bounded by only one of them + 16 | Conv.show(x) + | ^ type variable `a` is declared to implement 'Conv(Int)' and 'Conv(String)', and which of them this use needs is not known -error[type]: ambiguous method 'show' on a value of type `a`: provided by bounds Conv(Int), Conv(String) - --> two_bounds_of_one_trait__the_help_names_the_bounds_as_written.silt:19:3 +error[type]: type variable `a` is declared to implement 'Conv(Int)' and 'Conv(String)', and which of them this use needs is not known + --> two_bounds_of_one_trait__the_help_names_the_bounds_as_written.silt:20:13 | - 19 | x.show() - | ^^^^^^ ambiguous method 'show' on a value of type `a`: provided by bounds Conv(Int), Conv(String) - = help: the bounds `Sub(Int)` and `Sub(String)` both give `show`: call it from a function bounded by only one of them + 20 | Conv.show(x) + | ^ type variable `a` is declared to implement 'Conv(Int)' and 'Conv(String)', and which of them this use needs is not known diff --git a/tests/golden/typecheck/where_clauses/unknown_trait_in_where__no_cascade_on_method_calls.silt b/tests/golden/typecheck/where_clauses/unknown_trait_in_where__no_cascade_on_method_calls.silt index 30e45d72a..e02520c5e 100644 --- a/tests/golden/typecheck/where_clauses/unknown_trait_in_where__no_cascade_on_method_calls.silt +++ b/tests/golden/typecheck/where_clauses/unknown_trait_in_where__no_cascade_on_method_calls.silt @@ -9,7 +9,7 @@ -- stderr-not-contains: does not declare constraint type Box(a) { Box(a) } trait Loud { fn loud(self) -> String } -fn shout(x: a) -> String where a: Loud { x.loud() } +fn shout(x: a) -> String where a: Loud { Loud.loud(x) } fn f(x: a) -> String where a: Lowd { "{x.loud()}{shout(x)}" } trait Loud for Box(a) where a: Lowd { fn loud(self) -> String { match self { Box(v) -> v.loud() } } diff --git a/tests/golden/typecheck/where_clauses/where_clause_bound_arity__matching_arity_ok.silt b/tests/golden/typecheck/where_clauses/where_clause_bound_arity__matching_arity_ok.silt index 9addd53f4..ba130197c 100644 --- a/tests/golden/typecheck/where_clauses/where_clause_bound_arity__matching_arity_ok.silt +++ b/tests/golden/typecheck/where_clauses/where_clause_bound_arity__matching_arity_ok.silt @@ -4,7 +4,7 @@ trait Cast(to) { trait Cast(Float) for Int { fn cast(self) -> Float { 1.0 } } -fn g(x: a) -> Float where a: Cast(Float) { x.cast() } +fn g(x: a) -> Float where a: Cast(Float) { Cast.cast(x) } fn main() { println(g(42)) } diff --git a/tests/golden/typecheck/where_clauses/where_clause_bound_arity__parameterless_trait_ok.silt b/tests/golden/typecheck/where_clauses/where_clause_bound_arity__parameterless_trait_ok.silt index ab1756928..6b1db0ddc 100644 --- a/tests/golden/typecheck/where_clauses/where_clause_bound_arity__parameterless_trait_ok.silt +++ b/tests/golden/typecheck/where_clauses/where_clause_bound_arity__parameterless_trait_ok.silt @@ -4,5 +4,5 @@ trait Display2 { fn display2(self) -> String } -fn g(x: a) -> String where a: Display2 { x.display2() } +fn g(x: a) -> String where a: Display2 { Display2.display2(x) } fn main() { } diff --git a/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_matching_arity_runs.silt b/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_matching_arity_runs.silt index 611c16f09..6118e2500 100644 --- a/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_matching_arity_runs.silt +++ b/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_matching_arity_runs.silt @@ -6,11 +6,11 @@ trait Use for List(a) where a: Conv(Int) { fn use_it(self) -> Int { match self { [] -> 0 - [x, ..rest] -> x.conv() + rest.use_it() + [x, ..rest] -> Conv.conv(x) + Use.use_it(rest) } } } fn main() { let xs: List(Int) = [1, 2, 3] - println(xs.use_it()) + println(Use.use_it(xs)) } diff --git a/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_over_arity.silt b/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_over_arity.silt index 0365a3d9c..5833a300f 100644 --- a/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_over_arity.silt +++ b/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_over_arity.silt @@ -9,11 +9,11 @@ trait Use for List(a) where a: Cast(Int, String) { fn use_it(self) -> Float { match self { [] -> 0.0 - [x, ..rest] -> x.cast() + rest.use_it() + [x, ..rest] -> x.cast() + Use.use_it(rest) } } } fn main() { let xs: List(Int) = [1] - println(xs.use_it()) + println(Use.use_it(xs)) } diff --git a/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_over_arity_run.silt b/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_over_arity_run.silt index 8961d2dea..f6b262a68 100644 --- a/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_over_arity_run.silt +++ b/tests/golden/typecheck/where_clauses/where_clause_bound_arity_mismatch__impl_level_over_arity_run.silt @@ -8,11 +8,11 @@ trait Use for List(a) where a: Cast(Int, String) { fn use_it(self) -> Float { match self { [] -> 0.0 - [x, ..rest] -> x.cast() + rest.use_it() + [x, ..rest] -> x.cast() + Use.use_it(rest) } } } fn main() { let xs: List(Int) = [1] - println(xs.use_it()) + println(Use.use_it(xs)) } diff --git a/tests/golden/typecheck/where_clauses/where_constraint_alias__lambda_wrapper_rejects_int.silt b/tests/golden/typecheck/where_clauses/where_constraint_alias__lambda_wrapper_rejects_int.silt index 664bd39be..e2ef959b0 100644 --- a/tests/golden/typecheck/where_clauses/where_constraint_alias__lambda_wrapper_rejects_int.silt +++ b/tests/golden/typecheck/where_clauses/where_constraint_alias__lambda_wrapper_rejects_int.silt @@ -4,6 +4,6 @@ -- A where-constraint survives a lambda wrapper: calling f(42) is rejected. trait Greetable { fn greet(self) -> String } trait Greetable for String { fn greet(self) -> String { self } } -fn use_g(x: a) -> String where a: Greetable { x.greet() } +fn use_g(x: a) -> String where a: Greetable { Greetable.greet(x) } let f = { x -> use_g(x) } fn main() { f(42) } diff --git a/tests/golden/typecheck/where_clauses/where_constraint_alias__lambda_wrapper_valid_call.silt b/tests/golden/typecheck/where_clauses/where_constraint_alias__lambda_wrapper_valid_call.silt index 07b48c0fa..b6ffcc8a4 100644 --- a/tests/golden/typecheck/where_clauses/where_constraint_alias__lambda_wrapper_valid_call.silt +++ b/tests/golden/typecheck/where_clauses/where_constraint_alias__lambda_wrapper_valid_call.silt @@ -2,6 +2,6 @@ -- A valid call through the lambda wrapper still runs. trait Greetable { fn greet(self) -> String } trait Greetable for String { fn greet(self) -> String { self } } -fn use_g(x: a) -> String where a: Greetable { x.greet() } +fn use_g(x: a) -> String where a: Greetable { Greetable.greet(x) } let f = { x -> use_g(x) } fn main() { println(f("hello")) } diff --git a/tests/golden/typecheck/where_clauses/where_constraint_alias__let_alias_rejects_int.silt b/tests/golden/typecheck/where_clauses/where_constraint_alias__let_alias_rejects_int.silt index b18b783c8..ee5a04580 100644 --- a/tests/golden/typecheck/where_clauses/where_constraint_alias__let_alias_rejects_int.silt +++ b/tests/golden/typecheck/where_clauses/where_constraint_alias__let_alias_rejects_int.silt @@ -4,6 +4,6 @@ -- A where-constraint survives `let f = use_g`: calling f(42) is rejected. trait Greetable { fn greet(self) -> String } trait Greetable for String { fn greet(self) -> String { self } } -fn use_g(x: a) -> String where a: Greetable { x.greet() } +fn use_g(x: a) -> String where a: Greetable { Greetable.greet(x) } let f = use_g fn main() { f(42) } diff --git a/tests/golden/typecheck/where_clauses/where_constraint_alias__let_alias_valid_call.silt b/tests/golden/typecheck/where_clauses/where_constraint_alias__let_alias_valid_call.silt index 5aa637d71..f06428189 100644 --- a/tests/golden/typecheck/where_clauses/where_constraint_alias__let_alias_valid_call.silt +++ b/tests/golden/typecheck/where_clauses/where_constraint_alias__let_alias_valid_call.silt @@ -2,6 +2,6 @@ -- A valid call through the `let` alias still runs. trait Greetable { fn greet(self) -> String } trait Greetable for String { fn greet(self) -> String { self } } -fn use_g(x: a) -> String where a: Greetable { x.greet() } +fn use_g(x: a) -> String where a: Greetable { Greetable.greet(x) } let f = use_g fn main() { println(f("hello")) } diff --git a/tests/golden/typecheck/where_clauses/where_impl_header__bound_accepts_and_runs.silt b/tests/golden/typecheck/where_clauses/where_impl_header__bound_accepts_and_runs.silt index c450b623b..8a0279931 100644 --- a/tests/golden/typecheck/where_clauses/where_impl_header__bound_accepts_and_runs.silt +++ b/tests/golden/typecheck/where_clauses/where_impl_header__bound_accepts_and_runs.silt @@ -6,11 +6,11 @@ trait Greet for Int { fn greet(self) -> String { "int" } } trait Wrap { fn unwrap(self) -> String } trait Wrap for Box(a) where a: Greet { fn unwrap(self) -> String { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } -fn through(x: t) -> String where t: Wrap { x.unwrap() } +fn through(x: t) -> String where t: Wrap { Wrap.unwrap(x) } fn main() { - println(Box(42).unwrap()) + println(Wrap.unwrap(Box(42))) println(through(Box(7))) } diff --git a/tests/golden/typecheck/where_clauses/where_impl_header__bound_with_trait_argument_runs.silt b/tests/golden/typecheck/where_clauses/where_impl_header__bound_with_trait_argument_runs.silt index 5984e69ab..bec7d05c2 100644 --- a/tests/golden/typecheck/where_clauses/where_impl_header__bound_with_trait_argument_runs.silt +++ b/tests/golden/typecheck/where_clauses/where_impl_header__bound_with_trait_argument_runs.silt @@ -8,7 +8,7 @@ trait Foo for Box(a) where a: Conv(Int) { fn do_it(self) -> Int { match self { Wrap(x) -> { - let n: Int = x.conv() + let n: Int = Conv.conv(x) n + 100 } } @@ -16,5 +16,5 @@ trait Foo for Box(a) where a: Conv(Int) { } fn main() { let b: Box(String) = Wrap("five") - println(b.do_it()) + println(Foo.do_it(b)) } diff --git a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__generic_fn_propagates_positive.silt b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__generic_fn_propagates_positive.silt index 6a4a3fc30..52a50b533 100644 --- a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__generic_fn_propagates_positive.silt +++ b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__generic_fn_propagates_positive.silt @@ -3,8 +3,8 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Greet for Box(a) where a: Greet { fn greet(self) -> String { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } -fn use_box(b: Box(a)) -> String where a: Greet { b.greet() } +fn use_box(b: Box(a)) -> String where a: Greet { Greet.greet(b) } fn main() { println(use_box(Box(99))) } diff --git a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__generic_fn_propagates_rejection.silt b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__generic_fn_propagates_rejection.silt index 3cd777214..1098ee426 100644 --- a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__generic_fn_propagates_rejection.silt +++ b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__generic_fn_propagates_rejection.silt @@ -6,10 +6,10 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Greet for Box(a) where a: Greet { fn greet(self) -> String { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } -fn use_box(b: Box(a)) -> String where a: Greet { b.greet() } +fn use_box(b: Box(a)) -> String where a: Greet { Greet.greet(b) } fn main() { let bad = Box("hello") println(use_box(bad)) diff --git a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__impl_where_accepts_int.silt b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__impl_where_accepts_int.silt index ab290efc1..287392e92 100644 --- a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__impl_where_accepts_int.silt +++ b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__impl_where_accepts_int.silt @@ -3,9 +3,9 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Greet for Box(a) where a: Greet { fn greet(self) -> String { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } fn main() { - println(Box(42).greet()) + println(Greet.greet(Box(42))) } diff --git a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__impl_where_rejects_string.silt b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__impl_where_rejects_string.silt index 7d0b8447d..e096a1a26 100644 --- a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__impl_where_rejects_string.silt +++ b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__impl_where_rejects_string.silt @@ -6,10 +6,10 @@ trait Greet { fn greet(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Greet for Box(a) where a: Greet { fn greet(self) -> String { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } fn main() { let b = Box("hello") - println(b.greet()) + println(Greet.greet(b)) } diff --git a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__method_where_rejects_at_call_site.silt b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__method_where_rejects_at_call_site.silt index 6f81628ba..ee14e222c 100644 --- a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__method_where_rejects_at_call_site.silt +++ b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__method_where_rejects_at_call_site.silt @@ -1,7 +1,6 @@ -- cmd: check -- exit: 1 -- stderr-contains: adds the bound `a: Greet`, which the trait does not declare for it --- stderr-contains: type 'String' does not implement trait 'Greet' -- A bound on the impl's type variable belongs on the impl's header: a -- call through the trait does not know a method's own. type Box(a) { Box(a) } @@ -10,10 +9,10 @@ trait Greet for Int { fn greet(self) -> String { "int" } } trait Wrap { fn unwrap(self) -> String } trait Wrap for Box(a) { fn unwrap(self) -> String where a: Greet { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } fn main() { let b = Box("hello") - println(b.unwrap()) + println(Wrap.unwrap(b)) } diff --git a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__multi_constraint_missing_greet.silt b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__multi_constraint_missing_greet.silt index 1ef30c5c3..ff5360cf8 100644 --- a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__multi_constraint_missing_greet.silt +++ b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__multi_constraint_missing_greet.silt @@ -7,10 +7,10 @@ trait Loud { fn loud(self) -> String } trait Loud for Int { fn loud(self) -> String { "INT" } } trait Greet for Box(a) where a: Greet + Loud { fn greet(self) -> String { - match self { Box(inner) -> inner.loud() } + match self { Box(inner) -> Loud.loud(inner) } } } fn main() { let b = Box(5) - println(b.greet()) + println(Greet.greet(b)) } diff --git a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__multi_constraint_missing_loud.silt b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__multi_constraint_missing_loud.silt index 7fac70793..6dec5e80c 100644 --- a/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__multi_constraint_missing_loud.silt +++ b/tests/golden/typecheck/where_clauses/where_impl_level_enforcement__multi_constraint_missing_loud.silt @@ -7,10 +7,10 @@ trait Loud { fn loud(self) -> String } trait Greet for Int { fn greet(self) -> String { "int" } } trait Greet for Box(a) where a: Greet + Loud { fn greet(self) -> String { - match self { Box(inner) -> inner.greet() } + match self { Box(inner) -> Greet.greet(inner) } } } fn main() { let b = Box(5) - println(b.greet()) + println(Greet.greet(b)) } diff --git a/tests/heavy/integration.rs b/tests/heavy/integration.rs index 4ac5d5bf2..2a5803d8d 100644 --- a/tests/heavy/integration.rs +++ b/tests/heavy/integration.rs @@ -815,9 +815,9 @@ fn main() { let body = match http.get("http://127.0.0.1:{port}/test") { Ok(resp) -> match bytes.to_string(resp.body) { Ok(text) -> text - Err(e) -> "the body is no text: {e.message()}" + Err(e) -> "the body is no text: {Error.message(e)}" } - Err(e) -> "the request failed: {e.message()}" + Err(e) -> "the request failed: {Error.message(e)}" } channel.send(result_ch, body) }) diff --git a/tests/heavy/repl_session.rs b/tests/heavy/repl_session.rs index e8c1bf169..7c248b8d6 100644 --- a/tests/heavy/repl_session.rs +++ b/tests/heavy/repl_session.rs @@ -35,7 +35,7 @@ fn session(rounds: usize, waiting: bool) -> (Vec, Vec) { "trait Named for T{i} {{ fn name(self) -> String {{ \"t{i}\" }} }}" )); entries.push(format!( - "println(\"M {{f{i}(1)}} {{T{i} {{ a: 1 }}.name()}}\")" + "println(\"M {{f{i}(1)}} {{Named.name(T{i} {{ a: 1 }})}}\")" )); markers.push(entries.len()); entries.push(format!("let bad{i}: Int = \"s\"")); diff --git a/tests/heavy/runtime_scaling.rs b/tests/heavy/runtime_scaling.rs index 5a333df98..931deed8e 100644 --- a/tests/heavy/runtime_scaling.rs +++ b/tests/heavy/runtime_scaling.rs @@ -418,7 +418,7 @@ trait Size for Other{i} {{ ) }) .collect(); - let call = format!("x.{method}()"); + let call = format!("Size.{method}(x)"); let calls = [call.as_str(); 8].join(" + "); format!( "trait Size {{ diff --git a/tests/lang/builtin_structural_traits_tests.rs b/tests/lang/builtin_structural_traits_tests.rs index bbe5cdd56..c2e8c67b1 100644 --- a/tests/lang/builtin_structural_traits_tests.rs +++ b/tests/lang/builtin_structural_traits_tests.rs @@ -7,7 +7,7 @@ #[test] fn every_builtin_enum_has_stamps_for_policy_permitted_traits() { use silt::typechecker::__trait_init_fingerprint_check_program; - let (impls, _) = __trait_init_fingerprint_check_program(); + let impls = __trait_init_fingerprint_check_program(); // Built-in enums that should have all four built-in trait stamps // (every variant arg type is Compare/Equal/Hash/Display-able). for type_name in [ @@ -58,7 +58,7 @@ fn every_builtin_enum_has_stamps_for_policy_permitted_traits() { #[test] fn every_builtin_record_has_stamps_for_policy_permitted_traits() { use silt::typechecker::__trait_init_fingerprint_check_program; - let (impls, _) = __trait_init_fingerprint_check_program(); + let impls = __trait_init_fingerprint_check_program(); // time records — all four built-in trait stamps via // `register_structural_traits_for(time, &[...], all_auto_traits)`. for type_name in ["Instant", "Date", "Time", "DateTime", "Duration"] { diff --git a/tests/lang/deep_value_stack_tests.rs b/tests/lang/deep_value_stack_tests.rs index dbf1bab8b..2b0a3dfcf 100644 --- a/tests/lang/deep_value_stack_tests.rs +++ b/tests/lang/deep_value_stack_tests.rs @@ -91,7 +91,7 @@ fn deep_values_compare_order_and_hash() { &[ "a == b", "a < b", - "a.hash() == b.hash()", + "Hash.hash(a) == Hash.hash(b)", "set.length(set.from_list([a, b]))", ] ), diff --git a/tests/lang/fs_walk_stat_tests.rs b/tests/lang/fs_walk_stat_tests.rs index 04ed1c2b2..db34e8135 100644 --- a/tests/lang/fs_walk_stat_tests.rs +++ b/tests/lang/fs_walk_stat_tests.rs @@ -285,7 +285,7 @@ import string fn main() {{ match {call} {{ Ok(paths) -> string.join(list.sort(paths), "\n") - Err(e) -> "Err: {{e.message()}}" + Err(e) -> "Err: {{Error.message(e)}}" }} }} "# diff --git a/tests/lang/round76_assoc_cycle_tests.rs b/tests/lang/round76_assoc_cycle_tests.rs index 59dec8f98..70a9ab16c 100644 --- a/tests/lang/round76_assoc_cycle_tests.rs +++ b/tests/lang/round76_assoc_cycle_tests.rs @@ -39,7 +39,7 @@ trait Container for Int { fn main() { let x: Int = 7 - println(x.unwrap()) + println(Container.unwrap(x)) } "#; diff --git a/tests/lang/stage7_io_pool_tests.rs b/tests/lang/stage7_io_pool_tests.rs index af14a8d25..7a62287b2 100644 --- a/tests/lang/stage7_io_pool_tests.rs +++ b/tests/lang/stage7_io_pool_tests.rs @@ -455,8 +455,8 @@ fn main() {{ match task.deadline(time.ms(300), {{ -> fill(conn, chunk, 256) }}) {{ Err(task.Timeout) -> println("timed out") Ok(Ok(_)) -> println("the peer took everything") - Ok(Err(e)) -> println("a write failed: {{e.message()}}") - Err(e) -> println("a write failed: {{e.message()}}") + Ok(Err(e)) -> println("a write failed: {{Error.message(e)}}") + Err(e) -> println("a write failed: {{Error.message(e)}}") }} match tcp.write(conn, chunk) {{ Err(tcp.Closed) -> println("closed") @@ -563,7 +563,7 @@ fn main() {{ tries(100) match io.read_file("{file}") {{ Ok(_) -> println("read the file") - Err(e) -> println(e.message()) + Err(e) -> println(Error.message(e)) }} }} "# diff --git a/tests/lang/stale_method_row_test.rs b/tests/lang/stale_method_row_test.rs index 1a01c5af6..b54fe2cf5 100644 --- a/tests/lang/stale_method_row_test.rs +++ b/tests/lang/stale_method_row_test.rs @@ -7,11 +7,11 @@ use silt::session::testing::{session_with, test_path}; const A: &str = "pub type T { T(Int) }\npub trait Ta { fn m(self) -> String }\n\ trait Ta for T { fn m(self) -> String { \"a\" } }\n\ - pub fn via_a(t: T) -> String { t.m() }\n"; + pub fn via_a(t: T) -> String { Ta.m(t) }\n"; const B: &str = "import a\nimport a.{ T }\npub trait Tb { fn m(self) -> String }\n\ trait Tb for T { fn m(self) -> String { \"b\" } }\n\ - pub fn via_b(t: T) -> String { t.m() }\n"; -const C: &str = "import a\nimport a.{ T, Ta }\nfn main() {\n println(T(1).m())\n \ + pub fn via_b(t: T) -> String { Tb.m(t) }\n"; +const C: &str = "import a\nimport a.{ T, Ta }\nfn main() {\n println(Ta.m(T(1)))\n \ println(a.via_a(T(2)))\n}\n"; /// `b` gives `T` a second method `m`, by its own trait; then `b` drops @@ -44,7 +44,7 @@ fn a_dropped_trait_checked_first_leaves_no_row() { } /// `c` is checked before `b` is: the row still names `Tb`, which `c` -/// does not reach, and `a`'s `m` is lost. (On main b22fba2d: "unknown +/// does not name, and `a`'s `m` is lost. (On main b22fba2d: "unknown /// field or method 'm' on type T".) #[test] fn a_dropped_trait_not_yet_checked_leaves_no_row() { diff --git a/tests/lang/tcp_module_tests.rs b/tests/lang/tcp_module_tests.rs index 4472a466d..9e7f39ce3 100644 --- a/tests/lang/tcp_module_tests.rs +++ b/tests/lang/tcp_module_tests.rs @@ -44,7 +44,7 @@ import tcp fn main() { match tcp.listen("127.0.0.1:0") { Ok(_) -> "ok" - Err(e) -> e.message() + Err(e) -> Error.message(e) } } "#); @@ -85,18 +85,18 @@ fn main() { let result = match tcp.read(conn, 1024) { Ok(buf) -> match bytes.to_string(buf) { Ok(s) -> s - Err(e) -> e.message() + Err(e) -> Error.message(e) } - Err(e) -> e.message() + Err(e) -> Error.message(e) } tcp.close(conn) task.join(server) result } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } "# @@ -134,18 +134,18 @@ fn main() { let result = match tcp.read_exact(conn, 8) { Ok(buf) -> match bytes.to_string(buf) { Ok(s) -> s - Err(e) -> e.message() + Err(e) -> Error.message(e) } - Err(e) -> e.message() + Err(e) -> Error.message(e) } tcp.close(conn) task.join(server) result } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } "# @@ -182,10 +182,10 @@ fn main() { task.join(server) result } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } "# @@ -227,10 +227,10 @@ fn main() { task.join(server) result } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } "# diff --git a/tests/lang/tcp_mtls_tests.rs b/tests/lang/tcp_mtls_tests.rs index fcd7de307..561b436e7 100644 --- a/tests/lang/tcp_mtls_tests.rs +++ b/tests/lang/tcp_mtls_tests.rs @@ -184,17 +184,17 @@ fn main() -> String {{ Ok(ca) -> match tcp.accept(listener) {{ Ok(conn) -> match tcp.tls_server_mtls(conn, cert, key, ca) {{ Ok(_) -> "ok" - Err(e) -> "err:{{e.message()}}" + Err(e) -> "err:{{Error.message(e)}}" }} - Err(e) -> "accept:{{e.message()}}" + Err(e) -> "accept:{{Error.message(e)}}" }} - Err(e) -> "ca-parse:{{e.message()}}" + Err(e) -> "ca-parse:{{Error.message(e)}}" }} - Err(e) -> "key-parse:{{e.message()}}" + Err(e) -> "key-parse:{{Error.message(e)}}" }} - Err(e) -> "cert-parse:{{e.message()}}" + Err(e) -> "cert-parse:{{Error.message(e)}}" }} - Err(e) -> "listen:{{e.message()}}" + Err(e) -> "listen:{{Error.message(e)}}" }} }} "#, @@ -357,13 +357,13 @@ fn serve(conn, cert, key, done) {{ -- A TLS connection is not handed to tls_server again. let again = match tcp.tls_server(tls, cert, key) {{ Ok(_) -> "a second handshake" - Err(e) -> e.message() + Err(e) -> Error.message(e) }} let _ = tcp.write(tls, bytes.from_string("hello over TLS")) tcp.close(tls) channel.send(done, "served; {{again}}") }} - Err(e) -> channel.send(done, "err:{{e.message()}}") + Err(e) -> channel.send(done, "err:{{Error.message(e)}}") }} }} diff --git a/tests/lang/tcp_tls_tests.rs b/tests/lang/tcp_tls_tests.rs index 512981d6e..b863d7604 100644 --- a/tests/lang/tcp_tls_tests.rs +++ b/tests/lang/tcp_tls_tests.rs @@ -47,7 +47,7 @@ fn main() { Ok(_) -> "wrong: should error" Err(_) -> "errored" } - Err(e) -> "accept-err:{e.message()}" + Err(e) -> "accept-err:{Error.message(e)}" } }) time.sleep(time.ms(50)) @@ -55,7 +55,7 @@ fn main() { let _ = tcp.connect("127.0.0.1:{tcp.local_port(listener)}") task.join(server) } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } "# @@ -98,13 +98,13 @@ fn main() {{ Ok(key) -> match tcp.accept(listener) {{ Ok(conn) -> match tcp.tls_server(conn, cert, key) {{ Ok(_) -> "ok" - Err(e) -> "handshake-failed:{{e.message()}}" + Err(e) -> "handshake-failed:{{Error.message(e)}}" }} - Err(e) -> "accept:{{e.message()}}" + Err(e) -> "accept:{{Error.message(e)}}" }} - Err(e) -> "key-parse:{{e.message()}}" + Err(e) -> "key-parse:{{Error.message(e)}}" }} - Err(e) -> "cert-parse:{{e.message()}}" + Err(e) -> "cert-parse:{{Error.message(e)}}" }} }}) time.sleep(time.ms(50)) @@ -118,7 +118,7 @@ fn main() {{ }} task.join(server) }} - Err(e) -> e.message() + Err(e) -> Error.message(e) }} }} "#, @@ -225,13 +225,13 @@ fn main() {{ match task.deadline(time.ms(100), {{ -> tcp.tls_server(conn, cert, key) }}) {{ Ok(Ok(_)) -> println("a handshake with a silent client") Err(task.Timeout) -> println("given up") - Ok(Err(e)) -> println("another error: {{e.message()}}") - Err(e) -> println("another error: {{e.message()}}") + Ok(Err(e)) -> println("another error: {{Error.message(e)}}") + Err(e) -> println("another error: {{Error.message(e)}}") }} -- The connection of the handshake was closed from the server's side. match tcp.read(silent, 1) {{ Ok(data) -> println("the client reads {{bytes.length(data)}} bytes") - Err(e) -> println("the client's read fails: {{e.message()}}") + Err(e) -> println("the client's read fails: {{Error.message(e)}}") }} }} "#, diff --git a/tests/lang/wave1_frontend_tests.rs b/tests/lang/wave1_frontend_tests.rs index 0c7931b22..38d2fd27c 100644 --- a/tests/lang/wave1_frontend_tests.rs +++ b/tests/lang/wave1_frontend_tests.rs @@ -644,7 +644,7 @@ fn main() { _ -> "other" } }) let words = "a b c" |> string.split(" ") |> list.map { w -> string.to_upper(w) } - println(u.greet()) + println(Greet.greet(u)) println("{classify(first)} {sum_to(4)} {words} {older.age} {nested}") } "#, diff --git a/tests/lsp/lsp_semantic_tokens_tests.rs b/tests/lsp/lsp_semantic_tokens_tests.rs index f4886de7d..2d67d0693 100644 --- a/tests/lsp/lsp_semantic_tokens_tests.rs +++ b/tests/lsp/lsp_semantic_tokens_tests.rs @@ -86,3 +86,49 @@ fn semantic_tokens_full_returns_classified_tokens() { client.shutdown(); } + +/// A call through a trait (`Show.show(5)`): the trait's name is an +/// INTERFACE token, the method's a FUNCTION token, each where it is +/// written. +#[test] +fn semantic_tokens_of_a_call_through_a_trait() { + let mut client = LspClient::spawn(); + let uri = "file:///tmp/silt_sem_tokens_trait_call.silt"; + let src = "trait Show { fn show(self) -> String }\n\ + trait Show for Int { fn show(self) -> String { \"i\" } }\n\ + fn main() { println(Show.show(5)) }\n"; + client.did_open_and_wait(uri, src); + let resp = client.request( + "textDocument/semanticTokens/full", + json!({ "textDocument": { "uri": uri } }), + ); + let data = resp + .pointer("/result/data") + .and_then(|v| v.as_array()) + .unwrap_or_else(|| panic!("expected /result/data array; got: {resp}")); + let (mut line, mut start) = (0u64, 0u64); + let mut tokens: Vec<(u64, u64, u64, u64)> = Vec::new(); + for chunk in data.as_chunks::<5>().0 { + let dl = chunk[0].as_u64().expect("deltaLine"); + let ds = chunk[1].as_u64().expect("deltaStart"); + match dl { + 0 => start += ds, + _ => { + line += dl; + start = ds; + } + } + let len = chunk[2].as_u64().expect("length"); + tokens.push((line, start, len, chunk[3].as_u64().expect("tokenType"))); + } + // `fn main() { println(Show.show(5)) }`: `Show` at 20, `show` at 25. + assert!( + tokens.contains(&(2, 20, 4, TT_INTERFACE)), + "the trait's name: {tokens:?}" + ); + assert!( + tokens.contains(&(2, 25, 4, TT_FUNCTION)), + "the method's name: {tokens:?}" + ); + client.shutdown(); +} diff --git a/tests/lsp/main.rs b/tests/lsp/main.rs index dc7f707d2..203495e6b 100644 --- a/tests/lsp/main.rs +++ b/tests/lsp/main.rs @@ -48,7 +48,6 @@ mod round76_lsp_folding_no_dups_tests; mod round76_lsp_hover_stdlib_method_tests; mod round77_lsp_inlay_trait_default_tests; mod round80_lsp_round80_tests; -mod round81_lsp_dot_type_narrow_tests; mod round81_lsp_rename_user_shadow_tests; mod round83_lsp_selection_range_decl_bounds_tests; mod round84_lsp_selection_range_fn_body_tests; diff --git a/tests/lsp/rename_sweep/g1/main.silt b/tests/lsp/rename_sweep/g1/main.silt index c6b87d756..5a16bb404 100644 --- a/tests/lsp/rename_sweep/g1/main.silt +++ b/tests/lsp/rename_sweep/g1/main.silt @@ -30,7 +30,7 @@ fn pair((a, b): (Int, Int), P { x, y }) { trait Scale { fn scale(self, by: Int) -> Int { - self.size() * by + Scale.size(self) * by } fn size(self) -> Int } diff --git a/tests/lsp/rename_sweep/t1/main.silt b/tests/lsp/rename_sweep/t1/main.silt index f3e14fb66..7abdefc7c 100644 --- a/tests/lsp/rename_sweep/t1/main.silt +++ b/tests/lsp/rename_sweep/t1/main.silt @@ -1,6 +1,6 @@ trait Scale { fn scale(self, by: Int) -> Int { - self.size() * by + Scale.size(self) * by } fn size(self) -> Int } @@ -16,10 +16,10 @@ trait Scale for Box { } fn twice(x: a) -> Int where a: Scale { - x.scale(2) + x.size() + Scale.scale(x, 2) + Scale.size(x) } fn main() { let b = Box { w: 3 } - println(b.scale(2) + twice(b) + b.size()) + println(Scale.scale(b, 2) + twice(b) + Scale.size(b)) } diff --git a/tests/lsp/rename_sweep/t11/main.silt b/tests/lsp/rename_sweep/t11/main.silt index f13e53546..dbd61ce5e 100644 --- a/tests/lsp/rename_sweep/t11/main.silt +++ b/tests/lsp/rename_sweep/t11/main.silt @@ -16,7 +16,7 @@ trait Sized { trait Named: Sized { fn name(self) -> String fn both(self, other: Self) -> Int { - self.size() + other.size() + Sized.size(self) + Sized.size(other) } } @@ -44,7 +44,7 @@ fn depth(t: Tree(a)) -> Int { fn describe(x: t) -> String where t: Named + Sized { let n = 1 - let s = "äö€😀 {x.name()} 😀 {x.size() + n} 😀 {n}" + let s = "äö€😀 {Named.name(x)} 😀 {Sized.size(x) + n} 😀 {n}" "{s} {n}" } @@ -60,7 +60,7 @@ fn locals() -> Int { fn main() { let b = Box { w: 3 } println(describe(b)) - println(b.both(Box { w: 4 }) + locals() + second) + println(Named.both(b, Box { w: 4 }) + locals() + second) let Box { w } = b println(w) let Box { w: width } = b diff --git a/tests/lsp/rename_sweep/t18/impls.silt b/tests/lsp/rename_sweep/t18/impls.silt index 91f142fa0..c74f6fbc9 100644 --- a/tests/lsp/rename_sweep/t18/impls.silt +++ b/tests/lsp/rename_sweep/t18/impls.silt @@ -16,6 +16,6 @@ trait Area for shapes.Shape { pub fn total(xs: List(shapes.Shape)) -> Int { match xs { [] -> 0 - [x, ..rest] -> x.area() + total(rest) + [x, ..rest] -> Area.area(x) + total(rest) } } diff --git a/tests/lsp/rename_sweep/t18/main.silt b/tests/lsp/rename_sweep/t18/main.silt index 470aa6a77..69c791dad 100644 --- a/tests/lsp/rename_sweep/t18/main.silt +++ b/tests/lsp/rename_sweep/t18/main.silt @@ -3,7 +3,7 @@ import impls.{ Area } import shapes.{ Shape, Box, Dot } fn twice(x: a) -> Int where a: Area { - x.area() * 2 + Area.area(x) * 2 } fn main() { diff --git a/tests/lsp/rename_sweep/t19/main.silt b/tests/lsp/rename_sweep/t19/main.silt index 8bdfb8597..79e3e20a8 100644 --- a/tests/lsp/rename_sweep/t19/main.silt +++ b/tests/lsp/rename_sweep/t19/main.silt @@ -35,13 +35,13 @@ fn apply(f: Fn(Meters) -> Meters, pair: (Meters, Int)) -> {m: Meters, n: Int} { } fn get(c: t) -> ::Item where t: Container { - c.unwrap() + Container.unwrap(c) } fn main() { let w: Wide = Box { item: Meters(2) } let g = { x: Meters -> x } - let r = apply(g, (w.unwrap(), 3)) + let r = apply(g, (Container.unwrap(w), 3)) let v: List(Meters) = [r.m] let k = (Meters(4) as Meters) println(get(k) + get(Box { item: 1 }) + r.n) diff --git a/tests/lsp/rename_sweep/t3/other.silt b/tests/lsp/rename_sweep/t3/other.silt index c404f92cf..313775dc0 100644 --- a/tests/lsp/rename_sweep/t3/other.silt +++ b/tests/lsp/rename_sweep/t3/other.silt @@ -6,7 +6,7 @@ pub fn mk(w: Int) -> Int { } pub fn label(s: a) -> String where a: Named { - s.name() + Named.name(s) } pub fn pt() -> g.Point { diff --git a/tests/lsp/round75_lsp_trait_tests.rs b/tests/lsp/round75_lsp_trait_tests.rs index ea706005c..eea4b18ac 100644 --- a/tests/lsp/round75_lsp_trait_tests.rs +++ b/tests/lsp/round75_lsp_trait_tests.rs @@ -166,7 +166,7 @@ fn rename_trait_updates_impl_header_and_where_clause() { // references stale. let source = "trait Greet {\n fn hello(self) -> String\n}\n\ trait Greet for Int {\n fn hello(self) -> String { \"hi\" }\n}\n\ - fn x(n: a) -> String where a: Greet {\n n.hello()\n}\n"; + fn x(n: a) -> String where a: Greet {\n Greet.hello(n)\n}\n"; let mut client = LspClient::spawn(); let uri = unique_uri("rename_trait_xref"); client.did_open_and_wait(&uri, source); diff --git a/tests/lsp/round76_lsp_folding_no_dups_tests.rs b/tests/lsp/round76_lsp_folding_no_dups_tests.rs index 24f81b00c..520babcf8 100644 --- a/tests/lsp/round76_lsp_folding_no_dups_tests.rs +++ b/tests/lsp/round76_lsp_folding_no_dups_tests.rs @@ -91,7 +91,7 @@ trait T for W { } fn main() { let w = W { v: 1 } - w.a() + T.a(w) } "; client.did_open_and_wait(file, src); diff --git a/tests/lsp/round77_lsp_inlay_trait_default_tests.rs b/tests/lsp/round77_lsp_inlay_trait_default_tests.rs index 0a687ac39..daccb733a 100644 --- a/tests/lsp/round77_lsp_inlay_trait_default_tests.rs +++ b/tests/lsp/round77_lsp_inlay_trait_default_tests.rs @@ -271,12 +271,12 @@ trait Loud { fn loud(self) -> String fn twice(self) -> String { let me = self - \"{me.loud()}{me.loud()}\" + \"{Loud.loud(me)}{Loud.loud(me)}\" } } "; let with_impl = format!( - "{body}trait Loud for Int {{ fn loud(self) -> String {{ \"i\" }} }}\nfn main() {{ println(1.twice()) }}\n" + "{body}trait Loud for Int {{ fn loud(self) -> String {{ \"i\" }} }}\nfn main() {{ println(Loud.twice(1)) }}\n" ); let without_impl = format!("{body}fn main() {{ println(1) }}\n"); for (name, src) in [("with_impl", with_impl), ("without_impl", without_impl)] { @@ -284,7 +284,7 @@ trait Loud { let uri = format!("file:///tmp/silt_hover_trait_default_{name}.silt"); client.did_open_and_wait(&uri, &src); // `me` in the interpolation, and `self` in the `let`. - for (line, character) in [(4, 6), (3, 13)] { + for (line, character) in [(4, 16), (3, 13)] { let hover = client.hover(&uri, line, character); let shown = hover.to_string(); assert!( diff --git a/tests/lsp/round81_lsp_dot_type_narrow_tests.rs b/tests/lsp/round81_lsp_dot_type_narrow_tests.rs deleted file mode 100644 index 4a50c3313..000000000 --- a/tests/lsp/round81_lsp_dot_type_narrow_tests.rs +++ /dev/null @@ -1,273 +0,0 @@ -//! Round 81 (DX-G4): `textDocument/completion`'s dot-completion path -//! must narrow the surfaced method set to those valid for the -//! receiver's inferred type. -//! -//! Pre-round-81 behaviour: the dot-completion path emitted record -//! fields when applicable but never surfaced trait methods. As a -//! result, `xs.|` on a `let xs: List(Int)` produced an empty -//! completion list — silt was a "second source of truth" relative to -//! the typechecker because the LSP couldn't tell the user which -//! methods were dispatchable on a List. -//! -//! Round 81 ships a minimum-viable type-aware narrowing pass: -//! -//! - When the receiver is a let-bound local with a recoverable type -//! (annotation or initializer-inferred), the LSP filters the -//! emitted method set to methods declared for that type's -//! canonical head name. -//! - When the receiver type cannot be inferred narrowly (no -//! annotation, complex expression, generic stuck on type -//! variables), the LSP falls back to the union of every method -//! name declared in the program — discoverable but unfiltered. -//! -//! The minimum-viable contract: filtering NEVER hides completions on a -//! receiver whose type the LSP can't pin down. Out of scope for this -//! round: chained calls past the first dot, generic instantiation, -//! trait constraints. See `src/lsp/completion.rs::dot_completions` -//! and the `methods_for_receiver` helper for the narrowing logic. -//! -//! All tests drive a real `silt lsp` subprocess end-to-end over the -//! LSP JSON-RPC transport so the full pipeline (lex → parse → -//! typecheck → publish → completion) is exercised. - -use std::sync::atomic::{AtomicU64, Ordering}; - -use serde_json::{Value, json}; - -use crate::support::LspClient; - -static URI_COUNTER: AtomicU64 = AtomicU64::new(1); - -fn unique_uri(tag: &str) -> String { - let n = URI_COUNTER.fetch_add(1, Ordering::SeqCst); - format!("file:///tmp/silt_lsp_round81_{tag}_{n}.silt") -} - -/// Pull `(label, kind)` pairs out of either the bare-array or -/// `CompletionList` response shapes. Mirrors the helper in -/// `tests/lsp/lsp_anon_record_field_completion_tests.rs`. -fn extract_completion_labels(result: &Value) -> Vec { - let arr = if let Some(arr) = result.as_array() { - arr.clone() - } else if let Some(arr) = result.pointer("/items").and_then(|v| v.as_array()) { - arr.clone() - } else { - return Vec::new(); - }; - arr.iter() - .filter_map(|it| { - it.get("label") - .and_then(|l| l.as_str()) - .map(|s| s.to_string()) - }) - .collect() -} - -// ── (a) Typed List local — narrow to List methods ───────────────────── -// -// Receiver is `let xs: List(Int) = [1, 2, 3]`. The LSP must surface -// methods that exist on a `List(Int)` receiver — at minimum the -// auto-derived built-in trait methods (`display`, `equal`, `compare`, -// `hash`) — and must NOT surface methods that only exist on `String` -// receivers (e.g. user-declared trait methods on String, or — should -// the LSP ever start surfacing module-style helpers — `to_upper`, -// `chars`, `split`). -// -// We assert positive presence of `display` (List auto-derives Display -// per `register_builtin_trait_impls` policy) and absence of -// String-specific user trait method names defined in the source. Names -// like `to_upper` / `chars` / `split` are stdlib module functions -// (`string.to_upper(s)`), not methods on a String value, so a silt -// program never reaches the LSP with them in the AST — to make the -// "must NOT include obviously-wrong methods" assertion meaningful we -// declare a `trait UpperCaser for String { fn to_upper(self) ... }` -// in the source and assert that `to_upper` does NOT appear in the -// completion for the `List` receiver. Without narrowing, both -// `display` (from List's auto-derive) AND `to_upper` (from the user -// String impl) would appear in `xs.|`. With narrowing, only List -// methods survive. - -#[test] -fn dot_completion_on_typed_list_local_filters_to_list_methods() { - let mut client = LspClient::spawn(); - let uri = unique_uri("typed_list_narrow"); - // Declare a String-only trait impl in the source so the program - // has at least one method name that is incontestably wrong for a - // List receiver. Without narrowing, `to_upper` would be in the - // unfiltered union; the narrowed set must drop it. - let text = "trait UpperCaser { fn to_upper(self) -> String }\n\ - trait UpperCaser for String { fn to_upper(self) -> String { \"X\" } }\n\ - fn main() {\n\ - \x20\x20let xs: List(Int) = [1, 2, 3]\n\ - \x20\x20let _ = xs.\n\ - }\n"; - client.did_open_and_wait(&uri, text); - - // Cursor placement: line 4 (0-indexed), column 13 — right after - // the `.` in `xs.`. Counting: - // " let _ = xs." - // 0 1 - // 01234567890123 - // ^ char=13 sits one past the dot. - let resp = client.request( - "textDocument/completion", - json!({ - "textDocument": { "uri": uri }, - "position": { "line": 4, "character": 13 }, - "context": { "triggerKind": 2, "triggerCharacter": "." } - }), - ); - let result = resp.get("result").expect("completion has result"); - let labels = extract_completion_labels(result); - - // Positive: List auto-derives Display, so `display` MUST appear in - // the narrowed completion set. - assert!( - labels.contains(&"display".to_string()), - "List receiver completion must include `display` (auto-derived); \ - got labels: {labels:?}" - ); - // Negative: a String-only user trait method must NOT appear. - // Pre-round-81 (no narrowing), it would. - assert!( - !labels.contains(&"to_upper".to_string()), - "List receiver completion must NOT include String-only method \ - `to_upper`; got labels: {labels:?}" - ); - - client.shutdown(); -} - -// ── (b) Typed String local — narrow to String methods ──────────────── -// -// Mirror of (a). Receiver is `let s: String = "hello"`. The LSP must -// surface `display` (String auto-derives Display) AND the -// String-specific user trait method `to_upper` (declared in the -// source); it must NOT surface a List-only user trait method like -// `head_int` from the same source. - -#[test] -fn dot_completion_on_typed_string_local_filters_to_string_methods() { - let mut client = LspClient::spawn(); - let uri = unique_uri("typed_string_narrow"); - let text = "trait UpperCaser { fn to_upper(self) -> String }\n\ - trait UpperCaser for String { fn to_upper(self) -> String { \"X\" } }\n\ - trait IntListHead { fn head_int(self) -> Int }\n\ - trait IntListHead for List { fn head_int(self) -> Int { 0 } }\n\ - fn main() {\n\ - \x20\x20let s: String = \"hello\"\n\ - \x20\x20let _ = s.\n\ - }\n"; - client.did_open_and_wait(&uri, text); - - // Cursor: line 6, char=12 — after `let _ = s.` (10 chars before - // the `.` plus the `.` itself plus the leading two spaces gives 12). - // " let _ = s." - // 0 1 - // 012345678901 - // ^ char=12 - let resp = client.request( - "textDocument/completion", - json!({ - "textDocument": { "uri": uri }, - "position": { "line": 6, "character": 12 }, - "context": { "triggerKind": 2, "triggerCharacter": "." } - }), - ); - let result = resp.get("result").expect("completion has result"); - let labels = extract_completion_labels(result); - - // Positive: `display` (auto-derived for String) AND `to_upper` - // (user trait impl on String) must both appear. - assert!( - labels.contains(&"display".to_string()), - "String receiver completion must include `display` (auto-derived); \ - got labels: {labels:?}" - ); - assert!( - labels.contains(&"to_upper".to_string()), - "String receiver completion must include `to_upper` (user trait impl \ - on String); got labels: {labels:?}" - ); - // Negative: a List-only user trait method must NOT appear. - assert!( - !labels.contains(&"head_int".to_string()), - "String receiver completion must NOT include List-only method \ - `head_int`; got labels: {labels:?}" - ); - - client.shutdown(); -} - -// ── (c) Untyped local with unknowable type — full set fallback ─────── -// -// Receiver is bound to a complex expression whose inferred type is a -// stuck type variable (no annotation, no concrete initializer). The -// minimum-viable contract: when narrowing isn't safe, the LSP must -// fall back to the union of every method name declared in the program -// — `to_upper` AND `head_int` from the example source must both -// appear, because the LSP cannot prove either one wrong. -// -// Test name documents the limit: `untyped_local` here means a binding -// whose recoverable type is `None` from the LSP's vantage point. -// (Round 81 minimum-viable: any receiver expression that is not a -// straight identifier resolving to an inferred non-`_` type lands in -// the fallback set. Future rounds can tighten this for literals and -// chained calls.) - -#[test] -fn dot_completion_on_untyped_local_returns_full_set() { - let mut client = LspClient::spawn(); - let uri = unique_uri("untyped_fallback"); - // The receiver `x` is bound to a recursive call that the LSP - // cannot resolve to a concrete type — its `expr.ty` either stays - // an unresolved variable or is missing entirely after typecheck, - // depending on inference order. Either way the dot-completion - // path's `find_ident_type_by_name` returns `None` (it explicitly - // filters out types containing unresolved vars; see - // `src/lsp/ast_walk.rs::has_unresolved_vars`), so the receiver - // type stays `None` and the fallback union must surface both the - // String-only `to_upper` and the List-only `head_int`. - let text = "trait UpperCaser { fn to_upper(self) -> String }\n\ - trait UpperCaser for String { fn to_upper(self) -> String { \"X\" } }\n\ - trait IntListHead { fn head_int(self) -> Int }\n\ - trait IntListHead for List { fn head_int(self) -> Int { 0 } }\n\ - fn unknown(a) { unknown(a) }\n\ - fn main() {\n\ - \x20\x20let x = unknown(0)\n\ - \x20\x20let _ = x.\n\ - }\n"; - client.did_open_and_wait(&uri, text); - - // Cursor: line 7, char=12. - // " let _ = x." - // 0 1 - // 012345678901 - // ^ char=12 - let resp = client.request( - "textDocument/completion", - json!({ - "textDocument": { "uri": uri }, - "position": { "line": 7, "character": 12 }, - "context": { "triggerKind": 2, "triggerCharacter": "." } - }), - ); - let result = resp.get("result").expect("completion has result"); - let labels = extract_completion_labels(result); - - // Both user-declared trait methods must appear in the fallback set - // — narrowing only ever reduces noise; on an unknown receiver it - // must NOT silently drop completions. - assert!( - labels.contains(&"to_upper".to_string()), - "untyped receiver completion must include `to_upper` from the \ - fallback union (no narrowing took effect); got labels: {labels:?}" - ); - assert!( - labels.contains(&"head_int".to_string()), - "untyped receiver completion must include `head_int` from the \ - fallback union (no narrowing took effect); got labels: {labels:?}" - ); - - client.shutdown(); -} diff --git a/tests/lsp/stage5_session_tests.rs b/tests/lsp/stage5_session_tests.rs index d581281e6..63ae53ea7 100644 --- a/tests/lsp/stage5_session_tests.rs +++ b/tests/lsp/stage5_session_tests.rs @@ -129,11 +129,11 @@ fn editing_an_imported_file_republishes_its_importer() { fn closing_a_module_leaves_the_method_rows_of_the_others() { const A: &str = "pub type T { T(Int) }\npub trait Ta { fn m(self) -> String }\n\ trait Ta for T { fn m(self) -> String { \"a\" } }\n\ - pub fn via_a(t: T) -> String { t.m() }\n"; + pub fn via_a(t: T) -> String { Ta.m(t) }\n"; const B: &str = "import a\nimport a.{ T }\npub trait Tb { fn m(self) -> String }\n\ trait Tb for T { fn m(self) -> String { \"b\" } }\n\ - pub fn via_b(t: T) -> String { t.m() }\n"; - const C: &str = "import a\nimport a.{ T, Ta }\nfn main() {\n println(T(1).m())\n \ + pub fn via_b(t: T) -> String { Tb.m(t) }\n"; + const C: &str = "import a\nimport a.{ T, Ta }\nfn main() {\n println(Ta.m(T(1)))\n \ println(a.via_a(T(2)))\n}\n"; let dir = project("rows", &[("a.silt", A), ("b.silt", B), ("c.silt", C)]); let [a_uri, b_uri, c_uri] = ["a.silt", "b.silt", "c.silt"].map(|name| uri(&dir.join(name))); diff --git a/tests/meta/round80_dead_code_tests.rs b/tests/meta/round80_dead_code_tests.rs index d34287138..8b446b990 100644 --- a/tests/meta/round80_dead_code_tests.rs +++ b/tests/meta/round80_dead_code_tests.rs @@ -38,7 +38,7 @@ import tcp fn main() -> String {{ match tcp.connect_tls("{unused_port}", "localhost") {{ Ok(_) -> "unexpected ok" - Err(e) -> e.message() + Err(e) -> Error.message(e) }} }} "# @@ -71,16 +71,16 @@ fn main() -> String { match tcp.accept(listener) { Ok(conn) -> match tcp.tls_server(conn, bad_cert, bad_key) { Ok(_) -> "wrong: server expected to fail" - Err(e) -> e.message() + Err(e) -> Error.message(e) } - Err(e) -> e.message() + Err(e) -> Error.message(e) } }) time.sleep(time.ms(50)) let _ = tcp.connect("127.0.0.1:{tcp.local_port(listener)}") task.join(server) } - Err(e) -> e.message() + Err(e) -> Error.message(e) } } "# diff --git a/tests/typecheck/error_enum_message_rows_tests.rs b/tests/typecheck/error_enum_message_rows_tests.rs index 6b60b504f..81bbc32db 100644 --- a/tests/typecheck/error_enum_message_rows_tests.rs +++ b/tests/typecheck/error_enum_message_rows_tests.rs @@ -83,7 +83,7 @@ fn every_builtin_error_enum_has_a_message_row() { "import {module}\n\ fn main() {{\n\ let e = {module}.{call}\n\ - println(e.message())\n\ + println(Error.message(e))\n\ }}\n" ); let path = temp_silt_file(&format!("trait_{enum_name}"), &src);