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

Backend line-number computation doesn't account for underlying SourceFiles. #21762

Closed
bishabosha opened this issue Oct 14, 2024 · 1 comment · Fixed by #21763
Closed

Backend line-number computation doesn't account for underlying SourceFiles. #21762

bishabosha opened this issue Oct 14, 2024 · 1 comment · Fixed by #21763

Comments

@bishabosha
Copy link
Member

bishabosha commented Oct 14, 2024

Compiler version

3.5.1

Minimized code

The backend computes lines in the classfile by comparing the point offset to the source file of the current compilation unit.

This is problematic for code where the source file is derived from user code, i.e. with code-gen surrounding it.

The backend should at least be using the source file of the position, not the compilation unit, to compute the linenumber from offset, and ideally it should allow to hook-in customisations that allow for corrections such as "positionInUltimateSource"

here is the relevant line in BCodeSkelBuilder.
https://github.com/dotty-staging/dotty/blob/07f729e4322be097d54d4092420806ccf36b5f05/compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala#L625-L626

Expectation

Follow Scala 2, which does this

see https://github.com/scala/scala/blame/ceda7ea5a42168eacf4fe9b70f6e08e1684bbfda/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala#L498

@bishabosha bishabosha added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label area:backend and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 14, 2024
@bishabosha
Copy link
Member Author

bishabosha commented Oct 14, 2024

Actually, it seems it used to have the correct behaviour, but was broken by #9099 - which was meant to only be a refactor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant