Skip to content

Infix operation desugaring should preserve original span#22703

Open
rochala wants to merge 5 commits intoscala:mainfrom
rochala:fix-infix-spans
Open

Infix operation desugaring should preserve original span#22703
rochala wants to merge 5 commits intoscala:mainfrom
rochala:fix-infix-spans

Conversation

@rochala
Copy link
Contributor

@rochala rochala commented Mar 4, 2025

Found during debugging of #22566

Basically, we created new apply based on arg inside Parens that led to shorter span.

        case Parens(arg) =>
          Apply(sel, assignToNamedArg(arg) :: Nil)

@som-snytt
Copy link
Contributor

som-snytt commented Mar 6, 2025

Sample diff of my suggestion that moves the point

--- a/tests/explicit-nulls/neg/byname-nullables1.check
+++ b/tests/explicit-nulls/neg/byname-nullables1.check.out
@@ -1,4 +1,4 @@
--- Error: tests/explicit-nulls/neg/byname-nullables1.scala:10:6 --------------------------------------------------------
+-- Error: tests/explicit-nulls/neg/byname-nullables1.scala:10:12 -------------------------------------------------------
 10 |    f(x.fld != null) // error
    |      ^^^^^^^^^^^^^
    |      This argument was typed using flow assumptions about mutable variables

showing point (column of the error pos) is the op of the infix op, not start of left operand.

Copy link
Contributor

@som-snytt som-snytt left a comment

Choose a reason for hiding this comment

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

I'll look at the other pos diffs from my suggestion, to check if they also make sense.

I agree with the logic of the original change here, but can't explain why "composition of positions" is so hard. I understand my suggested change without thinking much.

@rochala rochala force-pushed the fix-infix-spans branch from b892b31 to cb2e767 Compare May 5, 2025 14:41
@rochala rochala requested a review from som-snytt May 5, 2025 16:29
@Gedochao
Copy link
Contributor

@rochala @som-snytt What's the status of this PR? is this still being worked on?

@Gedochao Gedochao added the stat: stale PR Marks any stale PRs, if no response is given, the PR qualifies as a one to close. label Feb 16, 2026
@som-snytt som-snytt removed the stat: stale PR Marks any stale PRs, if no response is given, the PR qualifies as a one to close. label Feb 16, 2026
@som-snytt
Copy link
Contributor

I rebased with a minor tweak. Probably will require an updated check file.

@rochala
Copy link
Contributor Author

rochala commented Feb 17, 2026

@som-snytt do you want to finish this or should I do it ?

@som-snytt
Copy link
Contributor

@rochala I will keep pushing. "Learning by breaking." I will notify if I hit my perplexity budget. Thanks!

@rochala
Copy link
Contributor Author

rochala commented Feb 17, 2026

Thanks again, had similar idea but for me it was Claude :D

@som-snytt
Copy link
Contributor

The CB c failure is mill, of course.

[94](https://github.com/scala/scala3/actions/runs/22076565460/job/63792831770?pr=22703#step:5:19095)
[127-1] - test.utest.AssertsTestsVersionSpecific 8ms
[127-1]   - assertCompileError 8ms
[127-1]     - failure 8ms
[127-1]       + 0 5ms  
[127-1]       + 1 0ms  
[127-1]       X 2 3ms 
[127-1]         java.lang.AssertionError: assertion failed: Compile error positions do not match
[127-1]         Expected Position
[127-1]         assertCompileError("1" * 2).check("")
[127-1]                            ^
[127-1]         Actual Position
[127-1]         assertCompileError("1" * 2).check("")
[127-1]                                ^
[127-1]           scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:10)
[127-1]           utest.CompileError.check(Errors.scala:184)
[127-1]           utest.CompileError.check$(Errors.scala:152)
[127-1]           utest.CompileError$Type.check(Errors.scala:204)
[127-1]           test.utest.AssertsTestsVersionSpecific$.tests$$anonfun$1$$anonfun$1$$anonfun$1$$anonfun$3(AssertsTestsVersionSpecific.scala:35)

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.

3 participants