Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: merge annotation.py and local.py #3456

Merged
merged 87 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
0869c4c
fix ordering
tserg May 24, 2023
d2b82fd
remove annotation wip
tserg May 24, 2023
76b94a6
move annotation into local analysis
tserg May 25, 2023
21a370c
improve annotation for visit_For
tserg May 25, 2023
2b4e7ef
fix lint
tserg May 25, 2023
236331c
fix some mypy
tserg May 25, 2023
905e3fb
fix assert and raise
tserg May 25, 2023
f9793e7
fix var name
tserg May 25, 2023
de231d5
remove catch for IfExp
tserg May 25, 2023
00f24b6
remove catch for unary
tserg May 25, 2023
614119d
remove catch for List
tserg May 25, 2023
16fbe48
remove catch for Constant
tserg May 25, 2023
23860e0
propagate attribute value type
tserg May 26, 2023
73b1ff0
remove catch for BinOp
tserg May 26, 2023
2af2c10
reorder fn validation before visiting body
tserg May 26, 2023
45be463
add some TODOs
tserg May 26, 2023
62b9516
clean up ignored nodes
tserg May 26, 2023
beb0c60
try interface fix
tserg May 26, 2023
a6cb50f
Revert "reorder fn validation before visiting body"
tserg May 26, 2023
837fd3f
Revert "try interface fix"
tserg May 26, 2023
ff602b1
move ast traversals in FnNodeVisitor ctor to helpers
tserg May 26, 2023
3672684
fix base visitor
tserg May 26, 2023
96a1cd0
fix mypy
tserg May 26, 2023
a4b008b
fix more mypy
tserg May 26, 2023
a0ff652
fix lint
tserg May 26, 2023
bf10a1a
fix lint
tserg May 27, 2023
1465973
add test
tserg May 31, 2023
39c78d3
Merge branch 'fix/if_exp' into refactor/annotation
tserg May 31, 2023
980004e
Merge branch 'master' of https://github.com/vyperlang/vyper into refa…
tserg Jun 1, 2023
51d2665
fix some mypy things
charles-cooper Jun 14, 2023
29792ae
add review comments
charles-cooper Jun 14, 2023
475e9c0
fix some more mypy things
charles-cooper Jun 14, 2023
f777fd9
Merge branch 'master' of https://github.com/vyperlang/vyper into refa…
tserg Jun 15, 2023
cc574f2
temporarily revert
tserg Jun 15, 2023
5442c37
change type to arg
tserg Jun 15, 2023
3713c0a
fix tuple
tserg Jun 15, 2023
ae0680f
fix tuple again
tserg Jun 15, 2023
aaea8b1
remove print
tserg Jun 15, 2023
f7279bc
try list iterator and call
tserg Jun 15, 2023
2b5ccc9
fix type list for literal lists in for loop
tserg Jun 16, 2023
00d4f9e
fix lint
tserg Jun 16, 2023
c196f66
fix nested empty lists
tserg Jun 16, 2023
e6f7288
improve nested list condition
tserg Jun 16, 2023
e99025e
use for else in visit_For
tserg Jun 16, 2023
da9a7cd
try typing every expr
tserg Jun 16, 2023
c024868
undo revert
tserg Jun 16, 2023
3507d0b
fix lint
tserg Jun 16, 2023
5450a1c
change types_from_List
tserg Jun 16, 2023
0b52d24
remove mypy hints
tserg Jun 16, 2023
302ebdb
clean up
tserg Jun 16, 2023
9ca2a2e
clean up visit_For
tserg Jun 16, 2023
bfa36a6
revert blank line deletion
tserg Jun 16, 2023
b6c8dde
fix typing
tserg Jun 17, 2023
fcc44a3
clean up type_ override
tserg Jun 17, 2023
df9354d
fix compare
tserg Jun 17, 2023
c513e36
chore: style things
charles-cooper Jun 19, 2023
275183e
fix builtins - inherit from base VyperType
charles-cooper Jun 19, 2023
aaf69c5
modify test
tserg Jun 19, 2023
b538481
remove validation in visit
tserg Jun 23, 2023
1b8dc29
fix attribute pure validation typ
tserg Jun 23, 2023
5d68679
add validate_expected_type to individual visits
tserg Jun 23, 2023
55c24e1
fix shift operator
tserg Jun 23, 2023
19c16e4
remove print
tserg Jun 23, 2023
1a9489d
fix compare
tserg Jun 23, 2023
8f7291c
fix indent
tserg Jun 23, 2023
c6b8024
skip downcast for bytestrings
tserg Jun 23, 2023
e861858
clarify binop rtyp
tserg Jun 23, 2023
16e2a96
clarify builtin comment
tserg Jun 23, 2023
7b0edf2
try removing type t branch
tserg Jun 23, 2023
39cccaa
Revert "try removing type t branch"
tserg Jun 23, 2023
827b852
undo change
tserg Jun 23, 2023
96a0e60
fix len infer arg types
tserg Jun 24, 2023
3c8589e
clean up local
tserg Jun 24, 2023
1a15bf3
fix lint
tserg Jun 24, 2023
b403bb8
fix comments
tserg Jun 24, 2023
e6d1ddb
fix visit_For iter visit
tserg Jun 24, 2023
b2f8570
clarify a branch
charles-cooper Jun 27, 2023
51701e9
clarify comment
charles-cooper Jun 27, 2023
6f535a1
add a comment
charles-cooper Jun 27, 2023
4e7b958
Merge branch 'master' of https://github.com/vyperlang/vyper into refa…
tserg Jul 17, 2023
c1b96ac
Merge branch 'master' of https://github.com/vyperlang/vyper into refa…
tserg Jul 26, 2023
b26c85c
fix merge conflict
tserg Jul 26, 2023
0b11dd0
Merge branch 'master' of https://github.com/vyperlang/vyper into refa…
tserg Sep 22, 2023
1d094c9
Merge branch 'master' of https://github.com/vyperlang/vyper into refa…
tserg Oct 9, 2023
acfe4de
Merge branch 'master' of https://github.com/vyperlang/vyper into refa…
tserg Oct 18, 2023
dbb25cb
polish some things, fix some potential spots for bugs
charles-cooper Oct 19, 2023
54c1908
remove bad typecheck
charles-cooper Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/parser/syntax/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,9 @@ def foo():
"""
@external
def foo():
x: DynArray[uint256, 3] = [1, 2, 3]
for i in [[], []]:
pass
x = i
""",
]

Expand Down
5 changes: 5 additions & 0 deletions vyper/ast/nodes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class Expr(VyperNode):

class UnaryOp(ExprNode):
op: VyperNode = ...
operand: VyperNode = ...

class USub(VyperNode): ...
class Not(VyperNode): ...
Expand All @@ -165,12 +166,15 @@ class BitXor(VyperNode): ...

class BoolOp(ExprNode):
op: VyperNode = ...
values: list[VyperNode] = ...

class And(VyperNode): ...
class Or(VyperNode): ...

class Compare(ExprNode):
op: VyperNode = ...
left: VyperNode = ...
right: VyperNode = ...

class Eq(VyperNode): ...
class NotEq(VyperNode): ...
Expand All @@ -179,6 +183,7 @@ class LtE(VyperNode): ...
class Gt(VyperNode): ...
class GtE(VyperNode): ...
class In(VyperNode): ...
class NotIn(VyperNode): ...

class Call(ExprNode):
args: list = ...
Expand Down
2 changes: 1 addition & 1 deletion vyper/builtins/_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def decorator_fn(self, node, context):
return decorator_fn


class BuiltinFunction:
class BuiltinFunction(VyperType):
_has_varargs = False
_kwargs: Dict[str, KwargSettings] = {}

Expand Down
6 changes: 6 additions & 0 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,12 @@ def evaluate(self, node):

return vy_ast.Int.from_node(node, value=length)

def infer_arg_types(self, node):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infer_arg_types of Len builtin was returning a python tuple of types.

self._validate_arg_types(node)
# return a concrete type
typ = get_possible_types_from_node(node.args[0]).pop()
return [typ]

def build_IR(self, node, context):
arg = Expr(node.args[0], context).ir_node
if arg.value == "~calldata":
Expand Down
283 changes: 0 additions & 283 deletions vyper/semantics/analysis/annotation.py

This file was deleted.

19 changes: 13 additions & 6 deletions vyper/semantics/analysis/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ class VyperNodeVisitorBase:
def visit(self, node, *args):
if isinstance(node, self.ignored_types):
return

# iterate over the MRO until we find a matching visitor function
# this lets us use a single function to broadly target several
# node types with a shared parent
for class_ in node.__class__.mro():
ast_type = class_.__name__
visitor_fn = getattr(self, f"visit_{ast_type}", None)
if visitor_fn:
return visitor_fn(node, *args)

node_type = type(node).__name__
visitor_fn = getattr(self, f"visit_{node_type}", None)
if visitor_fn is None:
raise StructureException(
f"Unsupported syntax for {self.scope_name} namespace: {node_type}", node
)
visitor_fn(node, *args)
raise StructureException(
f"Unsupported syntax for {self.scope_name} namespace: {node_type}", node
)
Loading
Loading