Open
Description
I often make the following stupid mistake:
from lpython import (i32, dataclass)
@dataclass
class FullFormValue:
list_i32 : list[i32]
string : str
foo : dict[str, FullFormValue]
DEAD_LIST : list[i32] = [-1] # Issue
ttype : FullFormValue = FullFormValue(DEAD_LIST, 'dimensions')
contents : FullFormValue = FullFormValue([1, 2], '')
foo = {'ttype' , ttype,
'contents', contents}
The error message is accurate, but could be more helpful:
/Users/brian/CLionProjects/lpython/src/bin/python /Users/brian/CLionProjects/lpython/lasr/LP-pycharm/issue2034.py
semantic error: All Set values must be of the same type for now
--> /Users/brian/CLionProjects/lpython/lasr/LP-pycharm/issue2034.py:15:7 - 16:28
|
15 | foo = {'ttype' , ttype,
| ^^^^^^^^^^^^^^^^^^^...
...
|
16 | 'contents', contents}
| ...^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LPython probably knows that the right-hand side should be a dict
, so it might be better if LPython told me of a type mismatch between the left-hand and right-hand sides, that the right-hand side should be a dict
and not a set
. Instead, it tells me that my set
is wrong. That's correct, of course, but it leads me in the wrong direction. If LPython allowed heterogeneous set
s, it wouldn't even report that error!