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

Fix parameter names not being checked #4061

Merged
merged 1 commit into from
Mar 19, 2022
Merged

Fix parameter names not being checked #4061

merged 1 commit into from
Mar 19, 2022

Conversation

SeanTAllen
Copy link
Member

@SeanTAllen SeanTAllen commented Mar 19, 2022

In 2018, when we removed case functions from Pony, we also removed the checking to make sure that parameters names were valid.

We've added checking of parameter names to make sure they match the naming rules for parameters in Pony.

Fixes #4054

@SeanTAllen SeanTAllen requested a review from a team March 19, 2022 15:32
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Mar 19, 2022
In 2018, when we
[removed case functions](#2542) from
Pony, we also removed the checking to make sure that parameters names were
valid.

We've added checking of parameter names to make sure they match the naming
rules for parameters in Pony.

Fixes #4054
Comment on lines +648 to +664
const char* bad5 =
"trait Foo\n"
" fun foo(_x: U64) => 3";

TEST_ERROR(bad5);

const char* bad5_be =
"trait Foo\n"
" be foo(_x: U64) => 3";

TEST_ERROR(bad5_be);

const char* bad5_new =
"class Foo\n"
" new create(_x: U64) => 3";

TEST_ERROR(bad5_new);
Copy link
Member Author

Choose a reason for hiding this comment

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

We used to have a test for this being allowed, however, under the rules it shouldnt be allowed. It was only allowed at some point because you could use _ in case method parameters. Otherwise it was supposed to be illegal.

@@ -553,31 +553,115 @@ TEST_F(SugarTest, FunctionNoReturnBody)
}


TEST_F(SugarTest, FunctionParamMustBeId)
TEST_F(SugarTest, MethodParamMustBeId)
Copy link
Member Author

Choose a reason for hiding this comment

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

because we check parameter names after sugaring be, fun, and new, i updated the tests to check for each type as it would otherwise be possible to break for say be because we were only checking fun.

accordingly, the test name was updated.

@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Mar 19, 2022
@SeanTAllen SeanTAllen merged commit 38066ae into main Mar 19, 2022
@SeanTAllen SeanTAllen deleted the 4054 branch March 19, 2022 18:15
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Mar 19, 2022
github-actions bot pushed a commit that referenced this pull request Mar 19, 2022
github-actions bot pushed a commit that referenced this pull request Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple underscores are allowed in names for methods
3 participants