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
db55dac1
Commit
db55dac1
authored
Jun 12, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix user type storage in scope
parent
28ff809a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
trans/transpiler/phases/typing/block.py
trans/transpiler/phases/typing/block.py
+2
-2
trans/transpiler/phases/typing/expr.py
trans/transpiler/phases/typing/expr.py
+3
-3
No files found.
trans/transpiler/phases/typing/block.py
View file @
db55dac1
...
...
@@ -6,7 +6,7 @@ from transpiler.phases.typing.expr import ScoperExprVisitor
from
transpiler.phases.typing.class_
import
ScoperClassVisitor
from
transpiler.phases.typing.scope
import
VarDecl
,
VarKind
,
ScopeKind
from
transpiler.phases.typing.types
import
BaseType
,
TypeVariable
,
FunctionType
,
IncompatibleTypesError
,
TY_MODULE
,
\
Promise
,
TY_NONE
,
PromiseKind
,
TupleType
,
UserType
Promise
,
TY_NONE
,
PromiseKind
,
TupleType
,
UserType
,
TypeType
@
dataclass
...
...
@@ -100,7 +100,7 @@ class ScoperBlockVisitor(ScoperVisitor):
def
visit_ClassDef
(
self
,
node
:
ast
.
ClassDef
):
ctype
=
UserType
(
node
.
name
)
self
.
scope
.
vars
[
node
.
name
]
=
VarDecl
(
VarKind
.
LOCAL
,
ctype
)
self
.
scope
.
vars
[
node
.
name
]
=
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
ctype
)
)
scope
=
self
.
scope
.
child
(
ScopeKind
.
CLASS
)
scope
.
obj_type
=
ctype
scope
.
class_
=
scope
...
...
trans/transpiler/phases/typing/expr.py
View file @
db55dac1
...
...
@@ -105,9 +105,9 @@ class ScoperExprVisitor(ScoperVisitor):
return
actual
def
visit_function_call
(
self
,
ftype
:
BaseType
,
arguments
:
List
[
BaseType
]):
if
isinstance
(
ftype
,
UserType
):
init
:
FunctionType
=
self
.
visit_getattr
(
ftype
,
"__init__"
)
ctor
=
FunctionType
(
init
.
args
[
1
:],
ftype
)
if
isinstance
(
ftype
,
TypeType
)
and
isinstance
(
ftype
.
type_object
,
UserType
):
init
:
FunctionType
=
self
.
visit_getattr
(
ftype
.
type_object
,
"__init__"
)
ctor
=
FunctionType
(
init
.
args
[
1
:],
ftype
.
type_object
)
return
self
.
visit_function_call
(
ctor
,
arguments
)
if
not
isinstance
(
ftype
,
FunctionType
):
raise
IncompatibleTypesError
(
f"Cannot call
{
ftype
}
"
)
...
...
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