-
-
Notifications
You must be signed in to change notification settings - Fork 420
Try using -Ymagic-offset-header to fixup line numbers
#5932
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
base: main
Are you sure you want to change the base?
Conversation
|
Next blocker seems to be that Mill's codegen desugars object `package` extends mill.Module {abstract class package_ extends _root_.mill.util.MainRootModule, mill.Module {This didn't affect the old error position fixup mechanism because it was line based, but the new one is offset based and so the longer line screws up all the subsequent offsets |
eead679 to
ae2002d
Compare
|
Seems we might not be able to merge this until Mill 2.x, as the new codegen would require that Fixable, but would break binary compatibility to fix |
ae2002d to
5262bce
Compare
318414b to
dce77b0
Compare
|
Got most tests passing with a modified codegen strategy, but will need to wait for Scala 3.8.0 to land with scala/scala3#24301 before we can merge this since that PR will likely miss 3.7.4 |
Requires
3.7.4-RC2for now, but will need to wait until3.7.4-finalbefore landingThis flag lets us remove a lot of our sketchy user-land workarounds to fix the filename and line numbers of errors:
AsmPositionUpdaterto which handled runtime exception error positionsPositionalMapperandTransformingReporterwhich handled compile-time error positions//SOURCECODE_ORIGINAL_FILE_PATHand//SOURCECODE_ORIGINAL_CODE_START_MARKER, which handledsourcecode.File/sourcecode.LinepositioningThis replaces it with a single
///SOURCE_CODE_STARTcomment referenced by-Ymagic-offset-header:SOURCE_CODE_START, which hooks in early enough in the compiler pipeline that all these downstream use cases can rely on itThe new
///SOURCE_CODE_STARTcomment relies on character offsets unlike line numbers like the previous hacks, and so we needed to change ourCodeGen.scalacode to avoid mangling lines within the user code block. Concretely, we needed to stop translatingobject packageintoabstract class package extends blahblahblah. Instead we translateobject packageintoclass _package(which takes up the same number of characters to avoid affecting offsets) and move theextends blahblahblahinto the generated code above the///SOURCE_CODE_STARTheader