daokoder / dao

Dao Programming Language
http://daoscript.org
Other
198 stars 19 forks source link

Inference also the "names" in a named tuple #547

Open dumblob opened 5 years ago

dumblob commented 5 years ago
$ dao -e 'invar t: tuple<y:any,any> = ( y=0, 1 )'
= ( 0, 1 )

$ dao -e 'invar t: tuple<y:any,any> = ( 0, 1 )'
= ( 0, 1 )

$ dao -e 'invar t: tuple<any,any> = ( y=0, 1 )'
[[Exception::Error]] --- General Error:
name not matched
In code snippet:
      1 :  DATA_I      :     2 ,     1 ,     1 ;     1;   1
>>    2 :  TUPLE       :     0 ,     2 ,     2 ;     1;   ( y=0, 1 )
      3 :  SETVG       :     2 ,     0 ,     6 ;     1;   t: tuple<any,any> = ( y=...
Raised by:  __main__(), at instruction 2 in line 1 in file "MainNamespace";

Dao already casts like follows, so the error above is confusing.

$ dao -e 'invar x = ( y=0, 1 ); invar y = (tuple<a:int, b:int>)x'
= ( 0, 1 )
dumblob commented 5 years ago

It's also interesting, that there are already more issues somehow related to tuples :wink:: https://github.com/daokoder/dao/issues/355 https://github.com/daokoder/dao/issues/433 https://github.com/daokoder/dao/issues/438 https://github.com/daokoder/dao/issues/472 https://github.com/daokoder/dao/issues/430