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 type parameters not being visible to a lambda type in a type alias #1633

Merged
merged 1 commit into from
Mar 4, 2017

Conversation

chalcolith
Copy link
Member

@chalcolith chalcolith commented Mar 4, 2017

Currently the following code does not compile:

type Foo[T] is { (T): T }

The compiler gives the error:

lambdaalias.pony:1:19: can't find definition of 'T'
type Foo[T] is { (T): T }

This PR allows the lambda type to find type parameters from an enclosing type alias, as well as class, actor, etc.

I don't think this should affect anything else, since the only other use of the collect_type_params() function is for sugaring object literals, which aren't allowed in a type alias. Please let me know if this change will have wider implications.

Copy link
Member

@jemc jemc left a comment

Choose a reason for hiding this comment

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

Great work! This seems right to me.

I just added a few small style consistency comments.


TEST_F(VerifyTest, LambdaTypeGenericAliased)
{
const char *good =
Copy link
Member

Choose a reason for hiding this comment

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

To be consistent with the other tests, could you use src as the name of the variable that holds the string for this source code, rather than good?

TEST_F(VerifyTest, LambdaTypeGenericAliased)
{
const char *good =
"type Foo[T] is { (T): T }";
Copy link
Member

Choose a reason for hiding this comment

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

To be consistent with the lambda type style used in other tests, could you remove the "extra" spaces inside the curly braces. That is, it would be consistent if it looked like: {(T): T}.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I have updated the commit.

@sylvanc
Copy link
Contributor

sylvanc commented Mar 4, 2017

Nice!

@sylvanc sylvanc added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Mar 4, 2017
@sylvanc sylvanc merged commit 611b5b6 into ponylang:master Mar 4, 2017
ponylang-main added a commit that referenced this pull request Mar 4, 2017
@chalcolith chalcolith deleted the lambda_alias branch March 4, 2017 21:14
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.

3 participants