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
89a863a1
Commit
89a863a1
authored
Sep 04, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some Python unification problems
parent
655b1d94
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
5 deletions
+9
-5
trans/tests/a_a_call_py_1.py
trans/tests/a_a_call_py_1.py
+0
-0
trans/transpiler/phases/emit_cpp/module.py
trans/transpiler/phases/emit_cpp/module.py
+2
-2
trans/transpiler/phases/typing/expr.py
trans/transpiler/phases/typing/expr.py
+7
-3
No files found.
trans/tests/call_py_1.py
→
trans/tests/
a_a_
call_py_1.py
View file @
89a863a1
File moved
trans/transpiler/phases/emit_cpp/module.py
View file @
89a863a1
...
...
@@ -76,8 +76,8 @@ class ModuleVisitor(BlockVisitor):
yield
""
elif
node
.
module_obj
.
is_python
:
for
alias
in
node
.
names
:
fty
=
alias
.
item_obj
assert
isinstance
(
fty
,
FunctionType
)
fty
=
alias
.
item_obj
.
resolve
()
#
assert isinstance(fty, FunctionType)
yield
from
self
.
emit_python_func
(
node
.
module
,
alias
.
name
,
alias
.
asname
or
alias
.
name
,
fty
)
else
:
...
...
trans/transpiler/phases/typing/expr.py
View file @
89a863a1
...
...
@@ -131,14 +131,18 @@ class ScoperExprVisitor(ScoperVisitor):
init
:
FunctionType
=
self
.
visit_getattr
(
ftype
,
"__init__"
).
remove_self
()
init
.
return_type
=
ftype
.
type_object
return
self
.
visit_function_call
(
init
,
arguments
)
if
not
isinstance
(
ftype
,
FunctionType
):
if
isinstance
(
ftype
,
FunctionType
):
ret
=
ftype
.
return_type
elif
isinstance
(
ftype
,
TypeVariable
):
ret
=
TypeVariable
()
else
:
from
transpiler.phases.typing.exceptions
import
NotCallableError
raise
NotCallableError
(
ftype
)
#is_generic = any(isinstance(arg, TypeVariable) for arg in ftype.to_list())
equivalent
=
FunctionType
(
arguments
,
ftype
.
return_type
)
equivalent
=
FunctionType
(
arguments
,
ret
)
equivalent
.
is_intermediary
=
True
ftype
.
unify
(
equivalent
)
return
ftype
.
return_type
return
equivalent
.
return_type
def
visit_Lambda
(
self
,
node
:
ast
.
Lambda
)
->
BaseType
:
argtypes
=
[
TypeVariable
()
for
_
in
node
.
args
.
args
]
...
...
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