Stream: beginners

Topic: Interesting behavior with opaque types


view this post on Zulip Isaac Van Doren (Oct 30 2023 at 01:43):

This produces a type error, as I would expect:

Foo := I64 I64

val : Foo
val = @Foo 1

whereas this type checks just fine:

Bar := Str Str

val : Bar
val = @Bar "foo"

Does anyone know what's going on here?

view this post on Zulip Brendan Hansknecht (Oct 30 2023 at 02:24):

Parsing bug that ignores the second variable?

» x : Str Str
… x = "test"

"test" : Str

view this post on Zulip Brendan Hansknecht (Oct 30 2023 at 02:24):

That or we parse correctly, but when type checking realize that Str can't have a type variable and ignore the type variable passed to it.

view this post on Zulip Isaac Van Doren (Oct 30 2023 at 02:25):

Ah yeah that makes sense. Interesting that it isn't an issue with I64

view this post on Zulip Brendan Hansknecht (Oct 30 2023 at 02:26):

Not sure why it happens to Str and not I64. Maybe they are handled diffrently by the type checker. Cause I64 is already an alias?

view this post on Zulip Brendan Hansknecht (Oct 30 2023 at 02:26):

I64: Num (Integer Signed64) or something like that. Don't remember exactly how it works

view this post on Zulip Isaac Van Doren (Oct 30 2023 at 02:39):

Mm that does sound promising


Last updated: Jul 06 2025 at 12:14 UTC