Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-compiler
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-compiler
Commits
d84f8bc7
Commit
d84f8bc7
authored
Jul 07, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dict typing
parent
637bee47
Changes
1
Show 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 @
d84f8bc7
...
...
@@ -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