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

Upgrade f-interpolator #13367

Merged
merged 10 commits into from
Feb 8, 2022
Merged

Upgrade f-interpolator #13367

merged 10 commits into from
Feb 8, 2022

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Aug 24, 2021

Fixes #9939
Fixes #11256
Fixes #11750
Fixes #13293

@som-snytt som-snytt force-pushed the issue/9939 branch 4 times, most recently from c2eb496 to 91ca4f9 Compare August 27, 2021 19:50
@som-snytt som-snytt closed this Sep 3, 2021
@som-snytt som-snytt reopened this Oct 7, 2021
@anatoliykmetyuk anatoliykmetyuk requested a review from dos65 October 18, 2021 09:05
@anatoliykmetyuk
Copy link
Contributor

@dos65 @som-snytt any news on this one?

@som-snytt
Copy link
Contributor Author

It's not pretty but is mergeable. Future improvements would include optimizing and constant folding.

I can give it my eyes one more time this week.

@anatoliykmetyuk
Copy link
Contributor

So you're still planning to do some work on it? Or can @dos65 review it?

@som-snytt
Copy link
Contributor Author

som-snytt commented Nov 9, 2021

I'll give it a quick pre-review and click ready for review.

(Edit: removed observation that any LOC is burdensome.)

Copy link
Contributor

@dos65 dos65 left a comment

Choose a reason for hiding this comment

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

@som-snytt Nice work! Glad to see that the parity with Scala2 is finally obtained.

I left some comments/suggestions

@som-snytt
Copy link
Contributor Author

Sorry I was busy this past week, I meant to update this over the weekend! Still plan to look at this next time I touch the keyboard. Thanks for giving it eyes!

@som-snytt som-snytt marked this pull request as ready for review November 23, 2021 06:44
@som-snytt
Copy link
Contributor Author

som-snytt commented Nov 23, 2021

I guess the best part is 850 lines added, 851 lines removed.

Edit: the other best part was figuring out again how to run a test.

@som-snytt som-snytt changed the title Basic wiring Upgrade f-interpolator Nov 23, 2021
@smarter smarter added this to the 3.2.0 milestone Dec 5, 2021
@anatoliykmetyuk anatoliykmetyuk requested a review from dos65 January 10, 2022 14:33
@anatoliykmetyuk
Copy link
Contributor

@dos65 @som-snytt what's the status on this one? Is the PR review-ready in which case WDYT about it @dos65 ?

@dos65
Copy link
Contributor

dos65 commented Jan 12, 2022

@anatoliykmetyuk I think it's almost ready to merge. The only thing I'm worried that the FormatChecker implementation might be simplified if it conversions would be based on Type instead of ClassTag + from general approach I see that ClassTag isn't used in this way in scala3-compiler.

@som-snytt Don't you mind if I'll try to address this thing and will do a PR onto your branch? I think I will have time for that on this week.

@som-snytt
Copy link
Contributor Author

My previous comment on use of ClassTag still seems true to me:

Actually, I want to backport to Scala 2, so a goal was for some target independence. That's useful for any future fixes or improvements.

ClassTag sufficed. I think I started by abstracting over Type but that was baroque.

I didn't follow up on ensuring s"hello, world" is a constant string, or s"hello, ${ "world" }" etc:

I'll take another look at the class structure. I remember an open issue was optimization or at least constant folding; not sure if that is better solved here or generally. Other optimizations would be along the lines of "replace %d with .toInt" or whatever.

@dos65
Copy link
Contributor

dos65 commented Jan 12, 2022

@som-snytt

Actually, I want to backport to Scala 2, so a goal was for some target independence.

What do you mean by backport to Scala2? Do you want to port it back? I thought that this PR is a port from Scala2 🤔

I didn't follow up on ensuring s"hello, world" is a constant string, or s"hello, ${ "world" }" etc:

I've checked this sample, it's constant. Is there anything else to check?

I think there is a need to ask someone from core compiler team for a final review as it's a large PR.
From my side, I see that it works well, implementation is close to scala2-compiler, all tests from Scala2 were ported and pass 🎉

@som-snytt
Copy link
Contributor Author

yes, I intended to backport the forwardport. 😄

I won't stand in the way of whatever you'd like to improve, for some definition of improve.

Mostly I feel that the compiler should not ingest all this code that ought to be library code, but the first step is just correctness. There is no binary compat constraint so it can be fixed/improved at any time.

@som-snytt
Copy link
Contributor Author

While I think of it, config.Settings is an example use of ClassTag to represent erased types in compiler.

@som-snytt
Copy link
Contributor Author

Embraced @dos65 's suggestions and dropped some code. Although I embraced the suggestions, I dropped some braces. I remember how nice it was to have the braces removed from my teeth in middle school.

@som-snytt som-snytt force-pushed the issue/9939 branch 2 times, most recently from ab6f29a to 9b66cef Compare January 28, 2022 10:38
@som-snytt
Copy link
Contributor Author

Improved test output to show where // error is extra or missing. A test had 50 errors, impossible to correlate while sober.

@anatoliykmetyuk
Copy link
Contributor

@som-snytt please let us know once this is review ready :)

@anatoliykmetyuk anatoliykmetyuk assigned som-snytt and unassigned dos65 Jan 28, 2022
@som-snytt
Copy link
Contributor Author

Definitely ready. I could definitely make improvements indefinitely.

Prefer a regex for collecting magic error comments.

Allow arbitrary space after line comment but warn that
no space `//error` disables that error, which is useful
for testing and development.
@som-snytt
Copy link
Contributor Author

Rebased on phase name conflict.

Tweaked the f-usages that required backslashes to obviate returning to it later.

An unbootstrapped compiler will show doubled backslash in a few messages:

<   |              octal escape literals are unsupported: use \u0000 instead
---
>   |              octal escape literals are unsupported: use \\u0000 instead

"Caveat backslasher."

Copy link
Contributor

@anatoliykmetyuk anatoliykmetyuk left a comment

Choose a reason for hiding this comment

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

LGTM🎉
Thanks @som-snytt for all the work, and @dos65 for reviewing it!

@anatoliykmetyuk anatoliykmetyuk merged commit 9f17663 into scala:main Feb 8, 2022
@smarter smarter added the release-notes Should be mentioned in the release notes label Feb 8, 2022
@mbovel
Copy link
Member

mbovel commented Feb 8, 2022

Non-bootstrapped tests are failing. See logs.

@mbovel
Copy link
Member

mbovel commented Feb 8, 2022

Could reproduce locally (sbt testCompilation t7292-removal):

-- Error: tests/neg/t7292-removal.scala:2:14 ---------------------------------------------------------------------------
2 |  val chr1 = '\0' // error
              ^
              octal escape literals are unsupported: use \\u0000 instead
-- Error: tests/neg/t7292-removal.scala:3:17 ---------------------------------------------------------------------------
3 |  val str1 = "abc\123456" // error
                 ^
                 octal escape literals are unsupported: use \\u0053 instead
-- Error: tests/neg/t7292-removal.scala:4:12 ---------------------------------------------------------------------------
4 |  val lf = '\012' // error
            ^
            octal escape literals are unsupported: use \n instead

The problem seems to be the duplicated slash in \\u.

@som-snytt
Copy link
Contributor Author

See my last comment. I wasn't sure about the protocol. On Scala 2, the change would wait until "restarr". Should I submit a revert for that commit? FSR, it wasn't clear to me that tests were run unbootstrapped.

@som-snytt som-snytt deleted the issue/9939 branch April 28, 2022 19:21
@Kordyjan Kordyjan modified the milestones: 3.2.0-RC1, 3.1.3 Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes Should be mentioned in the release notes
Projects
None yet
6 participants