Skip to content

Make Whitespace a proper trait rather than function to avoid unwanted implicit conversions#272

Merged
lihaoyi merged 1 commit intomasterfrom
whitespace-no-conversion
Mar 2, 2023
Merged

Make Whitespace a proper trait rather than function to avoid unwanted implicit conversions#272
lihaoyi merged 1 commit intomasterfrom
whitespace-no-conversion

Conversation

@lihaoyi
Copy link
Copy Markdown
Member

@lihaoyi lihaoyi commented Mar 1, 2023

Fixes #261, which is caused by the whitespace P[_] => P[Unit] implicits firing as implicit conversions rather than the implicit parameters they were originally intended to be. Since whitespace is meant to ignore failures, this caused failures caused by the Fail.! : P[String] to be ignored when implicitly converted to P[Unit]

The fix is to create a proper Whitespace trait to inherit from.

Note that this is a binary incompatible change. It's stacked on top of #271 for convenience, but should probably land separately after. The relevant changes are in this commit d87ab6d if anyone wants to look.

Note that I moved the custom whitespace tests to a scala2.12+ folder to skip them on 2.11. 2.11 does not support SAM conversion, which makes defining custom whitespaces a lot more boilerplatey. Can still be done, but no need to burden everyone with boilerplatey examples just to cater for the 2.11 folks in the test suite. Things are unlikely to break just for 2.11 anyway

@lihaoyi lihaoyi force-pushed the whitespace-no-conversion branch from db800f9 to d87ab6d Compare March 1, 2023 08:38
@lihaoyi
Copy link
Copy Markdown
Member Author

lihaoyi commented Mar 2, 2023

@lefou @lolgab if we expect the next version of Fastparse to be 3.0.0, then I'll merge this to get the bincompat breakage in before the version bump

@lefou
Copy link
Copy Markdown
Member

lefou commented Mar 2, 2023

Can you rebase this PR on top of #271, please?

@lihaoyi
Copy link
Copy Markdown
Member Author

lihaoyi commented Mar 2, 2023

@lefou should already be rebased

@lefou
Copy link
Copy Markdown
Member

lefou commented Mar 2, 2023

@lefou should already be rebased

I meant on top of master branch.

@lihaoyi lihaoyi force-pushed the whitespace-no-conversion branch from 439602f to 599c8ce Compare March 2, 2023 16:03
@lihaoyi
Copy link
Copy Markdown
Member Author

lihaoyi commented Mar 2, 2023

@lefou I squashesd it on top of latest master, we can use the Squash and Merge button to make sure the PR description is used on the final commit that ends up in master

Copy link
Copy Markdown
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Copy Markdown
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

The change looks good to me. But there are test failures now.

@lihaoyi lihaoyi force-pushed the whitespace-no-conversion branch from 599c8ce to 609470e Compare March 2, 2023 16:43
@lihaoyi lihaoyi merged commit 22051f0 into master Mar 2, 2023
@lefou lefou deleted the whitespace-no-conversion branch March 2, 2023 19:40
@lefou lefou added this to the 3.0.0 milestone Mar 2, 2023
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.

Capture success on failure if type is annotated or infered to P[Unit]

2 participants