Skip to content

Commit

Permalink
Reject invalid emit
Browse files Browse the repository at this point in the history
  • Loading branch information
cburgdorf committed Mar 24, 2021
1 parent 895b9b5 commit e4f5f65
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion analyzer/src/traversal/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ fn emit(
} = &stmt.kind
{
return match kind {
fe::Expr::Call { func, args } => {
fe::Expr::Call { func, args } if matches!(&func.kind, fe::Expr::Name(_)) => {
let event_name = expressions::expr_name_str(func)?;

return if let Some(event) = scope.borrow().contract_event_def(event_name) {
Expand Down
1 change: 1 addition & 0 deletions compiler/tests/compile_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use std::fs;
case("duplicate_var_in_contract_method.fe", "AlreadyDefined"),
case("emit_undefined_event.fe", "MissingEventDefinition"),
case("emit_without_call.fe", "EventInvocationExpected"),
case("emit_with_invalid_call.fe", "EventInvocationExpected"),
case("external_call_type_error.fe", "TypeError"),
case("external_call_wrong_number_of_params.fe", "WrongNumberOfParams"),
case("indexed_event.fe", "MoreThanThreeIndexedParams"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
contract Foo:
pub def foo():
emit MyEvent("foo", 1000)()
3 changes: 3 additions & 0 deletions foo.fe
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
contract Foo:
pub def foo():
emit MyEvent()()
1 change: 1 addition & 0 deletions newsfragments/211.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Properly reject invalid emit

0 comments on commit e4f5f65

Please sign in to comment.