Skip to content
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

Ensure event emits are type checked #202

Merged
merged 1 commit into from
Jan 25, 2021

Conversation

cburgdorf
Copy link
Collaborator

@cburgdorf cburgdorf commented Jan 22, 2021

What was wrong?

On master, the following would not raise an error even though it should:

contract Foo:
    event MyEvent:
        val_1: string100
        val_2: u8

    pub def foo():
        emit MyEvent("foo", 1000)

How was it fixed?

Basically reuse the call_arg that is defined in expression and a little bit of refactoring the event to expose all field types.

To-Do

  • OPTIONAL: Update Spec if applicable

  • Add entry to the release notes (may forgo for trivial changes)

  • Clean up commit history

@cburgdorf cburgdorf force-pushed the christoph/fix/event_calls branch 2 times, most recently from 6e83637 to d2fcc99 Compare January 22, 2021 12:38
@codecov-io
Copy link

codecov-io commented Jan 22, 2021

Codecov Report

Merging #202 (d2fcc99) into master (e2807d1) will increase coverage by 0.21%.
The diff coverage is 69.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #202      +/-   ##
==========================================
+ Coverage   77.51%   77.73%   +0.21%     
==========================================
  Files          46       46              
  Lines        3322     3323       +1     
==========================================
+ Hits         2575     2583       +8     
+ Misses        747      740       -7     
Impacted Files Coverage Δ
compiler/src/yul/operations/data.rs 80.95% <ø> (ø)
compiler/src/yul/runtime/mod.rs 0.00% <0.00%> (ø)
semantics/src/traversal/expressions.rs 69.95% <ø> (+0.44%) ⬆️
semantics/src/traversal/functions.rs 35.59% <ø> (-2.51%) ⬇️
semantics/src/namespace/events.rs 92.30% <75.00%> (-1.03%) ⬇️
semantics/src/traversal/_utils.rs 100.00% <0.00%> (+62.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2807d1...d2fcc99. Read the comment docs.

@@ -9,7 +9,7 @@ contract Foo:
s5: string100

pub def __init__(s1: string42, a: address, s2: string26, u: u256, s3: string100):
emit MyEvent(s2, u, s1, s3, a, "static string", "foo")
emit MyEvent(s2, u, s1, s3, a, "static string", string100("foo"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This came to my attention after I merged #201 so it sparked this PR to tighten our type checks.

contract Foo:
event MyEvent:
val_1: string100
val_2: u8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sanity it might be good to mark one of these as indexed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point 👍

@cburgdorf cburgdorf merged commit 4c8a5e0 into ethereum:master Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants