Open gmlewis opened 6 days ago
This still exists in version:
$ moon version --all
moon 0.1.20241017 (e833bec 2024-10-17) ~/.moon/bin/moon
moonc v0.1.20241017+e8d7befb8 ~/.moon/bin/moonc
moonrun 0.1.20241017 (e833bec 2024-10-17) ~/.moon/bin/moonrun
Here's a better example that demonstrates this compiler bug:
Given two different traits in one package:
pub trait Reader {
read(Self, Slice[Byte]) -> (Int, IOError?)
}
pub trait ByteReader {
read_byte(Self) -> (Byte, IOError?)
}
when those two traits are combined together in a different package:
typealias Slice[T] = @io.Slice[T]
typealias IOError = @io.IOError
pub trait Reader {
// @io.Reader
read(Self, Slice[Byte]) -> (Int, IOError?)
// @io.ByteReader
read_byte(Self) -> (Byte, IOError?)
}
the compiler reports Error [4018]
:
For completeness, the @flate.Reader
does indeed implement the read
method here:
https://github.com/gmlewis/moonbit-flate/pull/1#pullrequestreview-2379432826
fn read(self : Decompressor, b : Slice[Byte]) -> (Int, IOError?) {
...
}
/cc @Guest0x0
EDIT: Please see SIGNIFICANTLY BETTER demonstration test case in comment below.
In gmlewis/moonbit-flate, I have two public traits:
@flate.IOReader
@flate.IOWriter
In gmlewis/moonbit-gzip, I have two identical public traits:
@gzip.IOReader
@gzip.IOWriter
They should be 100% compatible.
However, when I attempt to use a
@gzip.IOReader
as a@flate.IOReader
(or a@gzip.IOWriter
as a@flate.IOWriter
), the compiler says that the methods are missing. See screenshots: