Skip to content

Commit

Permalink
use throwing in prefold
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Dec 26, 2023
1 parent 6838aa2 commit bce87d1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions vyper/semantics/analysis/pre_typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ def get_constants(node: vy_ast.Module) -> dict:
for n in c.value.get_descendants(include_self=True, reverse=True):
prefold(n, constants)

val = c.value.get_folded_value_maybe()
try:
val = c.value.get_folded_value_throwing()

# note that if a constant is redefined, its value will be overwritten,
# but it is okay because the syntax error is handled downstream
if val is not None:
# note that if a constant is redefined, its value will be overwritten,
# but it is okay because the syntax error is handled downstream
constants[name] = val
derived_nodes += 1
const_var_decls.remove(c)
except UnfoldableNode:
pass

if not derived_nodes:
break
Expand Down

0 comments on commit bce87d1

Please sign in to comment.