Skip to content

Better message for unexpected trailing commas in parameter lists#2954

Merged
axic merged 1 commit intoargotorg:developfrom
wadealexc:develop
Sep 25, 2017
Merged

Better message for unexpected trailing commas in parameter lists#2954
axic merged 1 commit intoargotorg:developfrom
wadealexc:develop

Conversation

@wadealexc
Copy link
Contributor

@wadealexc wadealexc commented Sep 22, 2017

Fixes #2579.

Improve error message for trailing commas in function signatures -

Trailing commas in function arguments, return parameters, event arguments, and modifier arguments now display the error message "Unexpected trailing comma in arguments"

{
parameters.push_back(parseVariableDeclaration(options));

if(m_scanner->currentToken() == Token::Comma && m_scanner->peekNextToken() == Token::RParen){
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this check only happens at the beginning of the parameter list, instead of the end.

Could you please add some tests to verify that?

Also, you accidentally added a binary file to this PR. Please remove it and rebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, fixed that. Will add boost tests and re-request

# true and continue as normal, either processing further commands in a script
# or returning the cursor focus back to the user in a Linux terminal.
../cpp-ethereum/build/eth/eth --test -d /tmp/test &
$ETH_PATH --test -d /tmp/test &
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to fix a change introduced by an earlier commit of yours. Can you please squash the two commits?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying to squash all of my commits, accidentally created more. Could you point me in the right direction for cleaning this up? I haven't submitted a PR to a repository before so I'm new to squashing/merging/etc.


while (m_scanner->currentToken() != Token::RParen)
{
expectToken(Token::Comma);
Copy link
Contributor

Choose a reason for hiding this comment

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

How about replacing those two checks with a single one before this expectToken? I think that should work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also please follow the coding style (space after if, before {, also no brackets needed if the body of a conditional is a single expression).

@axic
Copy link
Contributor

axic commented Sep 22, 2017

The tests look great and comprehensive!

@axic axic changed the title Fixed issue #2579 Better message for unexpected trailing commas in parameter lists Sep 22, 2017
function(uint a,) {}
}
)";
CHECK_PARSE_ERROR(text, "Unexpected trailing comma in arguments");
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this was the message suggested in the issue, but perhaps Unexpected trailing comma in parameter list is more universal given it is used on multiple places.

@chriseth @federicobond what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, let's go ahead with parameter list.

@wadealexc
Copy link
Contributor Author

Changed boost tests and error message to "Unexpected trailing comma in parameter list"

I've tried to squash my commits, but it keeps layering more on. I think as members of the repo you can squash when you merge. Otherwise, is there a different way for me to squash these?

@axic
Copy link
Contributor

axic commented Sep 25, 2017

@wadealexc squashed and rebased in your branch, please do not update it, it should be ready to merge now.

@axic axic merged commit a72237f into argotorg:develop Sep 25, 2017
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

Comments