Skip to content

fix[tool]: fix invalid quotes in -f cfg output #4672

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

Merged
merged 5 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 40 additions & 0 deletions tests/unit/cli/vyper_json/test_compile_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,46 @@ def test_compile_json_with_experimental_codegen():
assert venom["cfg_runtime"] == expected["cfg_runtime"]


def test_compile_json_subgraph_label():
foo_code = """
a: uint256
b: address

@internal
def _foo(f: uint256, g: address) -> uint256:
self.a = f
self.b = g
return self.a


@internal
def _bar(f: uint256, g: address) -> uint256:
self._foo(f, g)
self._foo(f, g)
return self.a


@external
def call_foo(amount: uint256, account: address) -> uint256:
return self._bar(amount, account)
"""
code = {
"language": "Vyper",
"sources": {"foo.vy": {"content": foo_code}},
"settings": {
"evmVersion": "cancun",
"optimize": "gas",
"venomExperimental": True,
"search_paths": ["."],
"outputSelection": {"*": ["cfg_runtime"]},
},
}
output_json = compile_json(code)
venom = output_json["contracts"]["foo.vy"]["foo"]["venom"]
# ensure that quotes are formatted properly in the output
assert 'subgraph "internal 0 _foo(uint256,address)_runtime"' in venom["cfg_runtime"]


def test_compile_json_without_experimental_codegen():
code = {
"language": "Vyper",
Expand Down
2 changes: 1 addition & 1 deletion vyper/venom/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _make_label(bb):

if not only_subgraph:
ret.append("digraph G {{")
ret.append(f'subgraph "{self.name}" {{')
ret.append(f"subgraph {repr(self.name)} {{")

for bb in self.get_basic_blocks():
for out_bb in bb.out_bbs:
Expand Down