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 optional argument type matching #584

Merged
merged 4 commits into from
Nov 15, 2024
Merged

Fix optional argument type matching #584

merged 4 commits into from
Nov 15, 2024

Conversation

Ph0enixKM
Copy link
Member

Currently declaring this function throws an error:

fun foo(arg: [] = [1, 2]) {

}

Even though this should work completely fine. The optional value is a subset of the argument type.

@Ph0enixKM Ph0enixKM requested a review from hdwalters November 11, 2024 11:09
@Ph0enixKM Ph0enixKM self-assigned this Nov 11, 2024
@Ph0enixKM Ph0enixKM requested a review from mks-h November 11, 2024 11:09
@Mte90
Copy link
Member

Mte90 commented Nov 11, 2024

maybe a test for this?
that just print succedeed?

Also I see that a lot of tests fails

@Ph0enixKM
Copy link
Member Author

@Mte90 I'm still working on it. I'll convert to draft to avoid confusion

@Ph0enixKM Ph0enixKM marked this pull request as draft November 11, 2024 11:14
@mks-h
Copy link
Member

mks-h commented Nov 11, 2024

Oops, totally a mistake of mine 😅

@Ph0enixKM
Copy link
Member Author

Ph0enixKM commented Nov 11, 2024

@mks-h no worries! It's a quick fix. I stumbled upon it when I was working on Amber's new marketing materials

@Ph0enixKM Ph0enixKM marked this pull request as ready for review November 11, 2024 11:21
Copy link
Member

@mks-h mks-h left a comment

Choose a reason for hiding this comment

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

Lets move the test for Generic "other" type into is_subset_of as the first match arm, and leave is_allowed_in intact. And +1 for validity tests on this.

Copy link
Contributor

@hdwalters hdwalters left a comment

Choose a reason for hiding this comment

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

Approved with suggestions.

src/modules/types.rs Outdated Show resolved Hide resolved
@Ph0enixKM Ph0enixKM requested a review from mks-h November 14, 2024 17:43
@Mte90 Mte90 merged commit 0239da2 into master Nov 15, 2024
1 check passed
@Ph0enixKM Ph0enixKM deleted the fix-generic-optional branch November 16, 2024 12:51
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