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
4e289013
Commit
4e289013
authored
May 25, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix TypeVar instantiation
parent
b4c7b909
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
trans/transpiler/phases/typing/stdlib.py
trans/transpiler/phases/typing/stdlib.py
+3
-6
No files found.
trans/transpiler/phases/typing/stdlib.py
View file @
4e289013
...
@@ -65,14 +65,11 @@ class StdlibVisitor(NodeVisitorSeq):
...
@@ -65,14 +65,11 @@ class StdlibVisitor(NodeVisitorSeq):
ty
=
FunctionType
(
arg_types
,
ret_type
)
ty
=
FunctionType
(
arg_types
,
ret_type
)
if
node
.
args
.
vararg
:
if
node
.
args
.
vararg
:
ty
.
variadic
=
True
ty
.
variadic
=
True
#arg_types.append(TY_VARARG)
if
self
.
cur_class
:
if
self
.
cur_class
:
assert
isinstance
(
self
.
cur_class
,
TypeType
)
assert
isinstance
(
self
.
cur_class
,
TypeType
)
if
isinstance
(
self
.
cur_class
.
type_object
,
ABCMeta
):
if
isinstance
(
self
.
cur_class
.
type_object
,
ABCMeta
):
self
.
cur_class
.
type_object
.
gen_methods
[
node
.
name
]
=
lambda
t
:
ty
.
gen_sub
(
t
,
self
.
typevars
)
self
.
cur_class
.
type_object
.
gen_methods
[
node
.
name
]
=
lambda
t
:
ty
.
gen_sub
(
t
,
self
.
typevars
)
else
:
else
:
# ty_inst = FunctionType(arg_types[1:], ret_type)
# self.cur_class.args[0].add_inst_member(node.name, ty_inst)
self
.
cur_class
.
type_object
.
methods
[
node
.
name
]
=
ty
.
gen_sub
(
self
.
cur_class
.
type_object
,
self
.
typevars
)
self
.
cur_class
.
type_object
.
methods
[
node
.
name
]
=
ty
.
gen_sub
(
self
.
cur_class
.
type_object
,
self
.
typevars
)
self
.
scope
.
vars
[
node
.
name
]
=
VarDecl
(
VarKind
.
LOCAL
,
ty
)
self
.
scope
.
vars
[
node
.
name
]
=
VarDecl
(
VarKind
.
LOCAL
,
ty
)
...
@@ -81,9 +78,9 @@ class StdlibVisitor(NodeVisitorSeq):
...
@@ -81,9 +78,9 @@ class StdlibVisitor(NodeVisitorSeq):
def
visit_Call
(
self
,
node
:
ast
.
Call
)
->
BaseType
:
def
visit_Call
(
self
,
node
:
ast
.
Call
)
->
BaseType
:
ty_op
=
self
.
visit
(
node
.
func
)
ty_op
=
self
.
visit
(
node
.
func
)
if
isinstance
(
ty_op
,
t
ype
):
if
isinstance
(
ty_op
,
TypeT
ype
):
return
ty_op
(
*
[
ast
.
literal_eval
(
arg
)
for
arg
in
node
.
args
])
return
ty_op
.
type_object
(
*
[
ast
.
literal_eval
(
arg
)
for
arg
in
node
.
args
])
raise
NotImplementedError
raise
NotImplementedError
(
ast
.
unparse
(
node
))
def
anno
(
self
)
->
"TypeAnnotationVisitor"
:
def
anno
(
self
)
->
"TypeAnnotationVisitor"
:
return
TypeAnnotationVisitor
(
self
.
scope
,
self
.
cur_class
)
return
TypeAnnotationVisitor
(
self
.
scope
,
self
.
cur_class
)
...
...
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