Skip to content

Commit

Permalink
Merge pull request #1442 from crytic/medariox-patch-1
Browse files Browse the repository at this point in the history
Fix detection of library events
  • Loading branch information
montyly authored Oct 26, 2022
2 parents 4b3d5f4 + 93a3699 commit ef61ca6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion slither/slithir/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ def extract_tmp_call(ins: TmpCall, contract: Optional[Contract]): # pylint: dis
# lib L { event E()}
# ...
# emit L.E();
if str(ins.ori.variable_right) in ins.ori.variable_left.events_as_dict:
if str(ins.ori.variable_right) in [f.name for f in ins.ori.variable_left.events]:
eventcall = EventCall(ins.ori.variable_right)
eventcall.set_expression(ins.expression)
eventcall.call_id = ins.call_id
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Lib": {},
"Test": {
"foo()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n}\n"
}
}
12 changes: 12 additions & 0 deletions tests/ast-parsing/library_event-0.8.16.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pragma solidity 0.8.16;

library Lib {
event Event();
}

contract Test {
function foo() external {
emit Lib.Event(); // This line specifically
}
}

1 change: 1 addition & 0 deletions tests/test_ast_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ def make_version(minor: int, patch_min: int, patch_max: int) -> List[str]:
Test("free_functions/new_operator.sol", ["0.8.12"]),
Test("free_functions/library_constant_function_collision.sol", ["0.8.12"]),
Test("ternary-with-max.sol", ["0.8.15"]),
Test("library_event-0.8.16.sol", ["0.8.16"]),
]
# create the output folder if needed
try:
Expand Down

0 comments on commit ef61ca6

Please sign in to comment.