-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[typetraits] Tuple type name confusion #7976
Comments
It actually seems to be even weirder (at least to me). It's not the order in which you declare the variable, but the order in which you print the names: import strformat, typetraits
type Person = tuple[name: string, age: int]
let
person1: Person = ("Peter", 30)
person2 = (name : "Peter", age : 30)
echo fmt"Tuple person1 of type {$person1.type} = {person1}"
echo fmt"Tuple person2 of type {$person2.type} = {person2}" prints them both as import strformat, typetraits
type Person = tuple[name: string, age: int]
let
person1: Person = ("Peter", 30)
person2 = (name : "Peter", age : 30)
echo fmt"Tuple person1 of type {$person2.type} = {person2}" # simply moved up
echo fmt"Tuple person2 of type {$person1.type} = {person1}" prints them as import strformat, typetraits
type Person = tuple[name: string, age: int]
let
person1: Person = ("Peter", 30)
person2 = (name : "Peter", age : 30)
echo fmt"Tuple person1 of type {name(person1.type)} = {person1}"
echo fmt"Tuple person2 of type {name(person2.type)} = {person2}" prints the first as |
see this comment #8569 (comment) |
Interesting, I just rebuilt Nim devel (a1e268e) and looks like this issue got fixed by a positive side-effect of some commit :D @timotheecour @Araq If you guys know which commit could have fixed this, please link that commit here for future reference. Thanks to whoever fixed this 👍 |
@kaushalmodi @Araq I verified that it was as a side effect of my recent PR #10071; not exactly sure why though. |
This issue has been fixed for a while; closing it. |
Hello,
I don't know how to correctly describe this bug.. see the below examples to understand the issue.
As
Person
is typetuple[name: string, age: int]
, the type "name" gets stuck to the first type I use to declare the variable.The text was updated successfully, but these errors were encountered: