Skip to content

Commit

Permalink
fix evm_version passing into compiler data
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Oct 1, 2023
1 parent e9ac957 commit 946f2cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
5 changes: 3 additions & 2 deletions tests/ast/test_pre_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_prerelease_invalid_version_pragma(file_version, mock_version):
#pragma optimize codesize
#pragma evm-version shanghai
""",
Settings(evm_version="shanghai", optimize=OptimizationLevel.GAS),
Settings(evm_version="shanghai", optimize=OptimizationLevel.CODESIZE),
),
(
"""
Expand Down Expand Up @@ -160,6 +160,7 @@ def test_prerelease_invalid_version_pragma(file_version, mock_version):


@pytest.mark.parametrize("code, expected_pragmas", pragma_examples)
def parse_pragmas(code, expected_pragmas):
def test_parse_pragmas(code, expected_pragmas, mock_version):
mock_version("0.3.10")
pragmas, _, _ = pre_parse(code)
assert pragmas == expected_pragmas
23 changes: 12 additions & 11 deletions vyper/compiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,18 @@ def compile_codes(
# make IR output the same between runs
codegen.reset_names()

with anchor_evm_version(settings.evm_version):
compiler_data = CompilerData(
source_code,
contract_name,
interfaces,
source_id,
settings,
storage_layout_override,
show_gas_estimates,
no_bytecode_metadata,
)
compiler_data = CompilerData(
source_code,
contract_name,
interfaces,
source_id,
settings,
storage_layout_override,
show_gas_estimates,
no_bytecode_metadata,
)
_ = compiler_data._generate_ast
with anchor_evm_version(compiler_data.settings.evm_version):
for output_format in output_formats[contract_name]:
if output_format not in OUTPUT_FORMATS:
raise ValueError(f"Unsupported format type {repr(output_format)}")
Expand Down
1 change: 1 addition & 0 deletions vyper/compiler/phases.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(
@cached_property
def _generate_ast(self):
settings, ast = generate_ast(self.source_code, self.source_id, self.contract_name)

# validate the compiler settings
# XXX: this is a bit ugly, clean up later
if settings.evm_version is not None:
Expand Down

0 comments on commit 946f2cf

Please sign in to comment.