poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[BUG] confusing type error


From: apache2
Subject: [BUG] confusing type error
Date: Tue, 22 Mar 2022 18:31:32 +0100
User-agent: Mutt/1.9.3 (2018-01-21)

Hmm, this looks like a bug to me:

#!!# type Bar = int;
#!!# type Foo = struct { type Bar = union { int a == 2; int b; }; var bar = 
Bar{b=1}; method x  = int:{ return bar; } };
<stdin>:1:107: error: returning an expression of the wrong type
<stdin>:1:107: error: expected Bar, got Bar
type Foo = struct { type Bar = union { int a == 2; int b; }; var bar = 
Bar{b=1}; method x  = int:{ return bar; } };;

The "expected Bar" it complains about is from "type Bar = int", but that's not 
very clear from the error message.
In any case the "method x = int:" said "int", so I would expect it to "expected 
int, got Bar" in any case. It shouldn't use the type alias "Bar" from the outer 
scope when "int" is clearly referenced.


Here is the error without the "type Bar = int" prelude:
Type ".exit" to leave the program.
#!!# type Foo = struct { type Bar = union { int a == 2; int b; }; var bar = 
Bar{b=1}; method x  = int:{ return bar; } };
<stdin>:1:107: error: returning an expression of the wrong type
<stdin>:1:107: error: expected int, got Bar
type Foo = struct { type Bar = union { int a == 2; int b; }; var bar = 
Bar{b=1}; method x  = int:{ return bar; } };;
                                                                                
                          ^~~

The latter makes much more sense to me :-)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]