Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tom Niget
typon
Commits
18de5bc4
Commit
18de5bc4
authored
Jul 07, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dict typing
parent
9d41a0a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
trans/transpiler/phases/typing/expr.py
trans/transpiler/phases/typing/expr.py
+4
-4
No files found.
trans/transpiler/phases/typing/expr.py
View file @
18de5bc4
...
...
@@ -147,10 +147,10 @@ class ScoperExprVisitor(ScoperVisitor):
raise
IncompatibleTypesError
(
f"
{
e
}
in `
{
ast
.
unparse
(
node
)
}
`"
)
def
visit_Attribute
(
self
,
node
:
ast
.
Attribute
)
->
BaseType
:
ltype
=
self
.
visit
(
node
.
value
)
try
:
ltype
=
self
.
visit
(
node
.
value
)
return
self
.
visit_getattr
(
ltype
,
node
.
attr
)
except
IncompatibleTypesError
as
e
:
except
Exception
as
e
:
raise
IncompatibleTypesError
(
f"
{
e
}
in `
{
ast
.
unparse
(
node
)
}
`"
)
def
visit_getattr
(
self
,
ltype
:
BaseType
,
name
:
str
):
...
...
@@ -191,11 +191,11 @@ class ScoperExprVisitor(ScoperVisitor):
def
visit_Dict
(
self
,
node
:
ast
.
Dict
)
->
BaseType
:
if
not
node
.
keys
:
return
PyDict
(
TypeVariable
())
return
PyDict
(
TypeVariable
()
,
TypeVariable
()
)
keys
=
[
self
.
visit
(
e
)
for
e
in
node
.
keys
]
values
=
[
self
.
visit
(
e
)
for
e
in
node
.
values
]
if
len
(
set
(
keys
))
!=
1
or
len
(
set
(
values
))
!=
1
:
raise
NotImplementedError
(
"Dict with different types not handled yet
"
)
raise
NotImplementedError
(
f"Dict with different types not handled yet in `
{
ast
.
unparse
(
node
)
}
`
"
)
return
PyDict
(
keys
[
0
],
values
[
0
])
def
visit_Subscript
(
self
,
node
:
ast
.
Subscript
)
->
BaseType
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment