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

REPL: scribe macro NPE when the scala source file is virtual #397

Closed
bishabosha opened this issue Feb 5, 2023 · 4 comments
Closed

REPL: scribe macro NPE when the scala source file is virtual #397

bishabosha opened this issue Feb 5, 2023 · 4 comments

Comments

@bishabosha
Copy link

bishabosha commented Feb 5, 2023

Scala compiler can accept virtual source files, e.g. in the REPL (and e.g. a hypothetical improved Zinc implementation). In these cases the "jpath" of the SourceFile can be null, causing a crash:

scala> scribe.info("foo")
-- Error: ----------------------------------------------------------------------
 1 |scribe.info("foo")
   |                  ^
   |Exception occurred while executing macro expansion.
   |java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.getFileName()" because the return value of "scala.quoted.Quotes$reflectModule$SourceFileMethods.jpath(Object)" is null
   |	at sourcecode.Macros$.fileNameImpl(Macros.scala:155)
   |
   |----------------------------------------------------------------------------
   |Inline stack trace
   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   |This location contains code that was inlined from Macros.scala:33
    ----------------------------------------------------------------------------
1 error found
@bishabosha
Copy link
Author

bishabosha commented Feb 5, 2023

For these virtual files the name and path properties should still have values

@darkfrog26
Copy link
Contributor

@bishabosha thanks for pointing this out. This appears to be a bug in https://github.com/com-lihaoyi/sourcecode causing this, but see the issue I linked above to get this resolved.

@darkfrog26
Copy link
Contributor

@bishabosha This should be fixed in the latest release.

@bishabosha
Copy link
Author

nice!

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

No branches or pull requests

2 participants