Skip to content

[BREAKING] Remove emit workaround#4179

Merged
axic merged 1 commit intodevelopfrom
emitWorkaround
Jun 11, 2018
Merged

[BREAKING] Remove emit workaround#4179
axic merged 1 commit intodevelopfrom
emitWorkaround

Conversation

@erak
Copy link
Copy Markdown
Collaborator

@erak erak commented May 23, 2018

Closes #4107.

This PR introduces emit as a proper keyword instead of parsing it as identifier.

Copy link
Copy Markdown
Contributor

@chriseth chriseth left a comment

Choose a reason for hiding this comment

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

Please add an assert to parseEmitStatement which checks for the emit keyword.

@chriseth
Copy link
Copy Markdown
Contributor

should this target 050?

@erak erak force-pushed the emitWorkaround branch from 0cdf79a to 9c1744b Compare May 25, 2018 10:49
@erak
Copy link
Copy Markdown
Collaborator Author

erak commented May 25, 2018

@chriseth I added the assertion you've requested.

Changelog.md Outdated
### 0.5.0 (unreleased)

Compiler features:
* Parser: Introduce emit as a keyword instead of parsing it as identifier.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need to escape emit with the double backticks.


ASTPointer<EmitStatement> Parser::parseEmitStatement(ASTPointer<ASTString> const& _docString)
{
solAssert(m_scanner->currentToken() == Token::Emit, "Expected emit token.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should use expectToken.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@axic, @chriseth requested an assertion here, but using expectToken seems to be more consistent with the rest of the parser. I'd be in favor of rather reporting a fatal parser error than raising an interal compiler error.

Copy link
Copy Markdown
Contributor

@axic axic May 30, 2018

Choose a reason for hiding this comment

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

Well it will not be triggered, but mostly we use expectToken and not solAssert in this file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought that it would be invalid use of the function to call it when there is no emit token, but yeah, expectToken is probably still better.

contract C {
event A();
function f() {
emit A();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm sure there's a test like this already?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@axic We have some syntax tests that cover the usage of emit with non-event types, but none that doesn't expect parser / type errors. So I think this should be added.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you sure? event_emit_simple in SolidityNameAndTypeResolution seems to be a duplicate of this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@axic Oh, you're right. I forgot to search in SolidityNameAndTypeResolution. Will remove this one then.

@erak erak force-pushed the emitWorkaround branch 2 times, most recently from 9b2c622 to 520e252 Compare May 30, 2018 11:40
@erak
Copy link
Copy Markdown
Collaborator Author

erak commented May 30, 2018

@axic @chriseth I think this is ready now for a final review.

axic
axic previously approved these changes May 30, 2018
@axic
Copy link
Copy Markdown
Contributor

axic commented May 30, 2018

It is failing:

*** 14 failures are detected in the test module "SolidityTests"

@axic
Copy link
Copy Markdown
Contributor

axic commented May 30, 2018

Also please rebase after #4178 was merged, perhaps some tests would need to be changed.

@erak
Copy link
Copy Markdown
Collaborator Author

erak commented May 30, 2018

@axic I will have a look why they are failing.

@erak erak force-pushed the emitWorkaround branch 3 times, most recently from 0f5f378 to d54dbff Compare June 5, 2018 17:24
@axic
Copy link
Copy Markdown
Contributor

axic commented Jun 11, 2018

It is weird that no tests seem to need an update. Does this fully disable invoking events without emit outside of 0.5.0?

@axic
Copy link
Copy Markdown
Contributor

axic commented Jun 11, 2018

The check in TypeChecker should have the warning (Invoking events without "emit" prefix is deprecated.) removed and only keeping the error. I'd also tend to say that instead of TypeError, this should be a SyntaxError and as such may deserve its place in SyntaxChecker, if it not too big of an overhead.

@axic axic changed the title Remove emit workaround [BREAKING] Remove emit workaround Jun 11, 2018
@axic axic force-pushed the emitWorkaround branch from d54dbff to 8f2de39 Compare June 11, 2018 17:10
@axic
Copy link
Copy Markdown
Contributor

axic commented Jun 11, 2018

It may be better to keep this for using the keyword and having a separate PR cleaning up the rest.

Changelog.md Outdated
Language Features:
* General: Support ``pop()`` for storage arrays.
Compiler features:
* Parser: Introduce ``emit`` as a keyword instead of parsing it as identifier.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is actually a breaking change, because emit cannot be used as an identifier anymore. Moved.

@axic axic force-pushed the emitWorkaround branch from 8f2de39 to 2e9f5d1 Compare June 11, 2018 20:21
@axic axic merged commit 8999a2f into develop Jun 11, 2018
@axic axic deleted the emitWorkaround branch June 11, 2018 22:00
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.

4 participants