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

Quasiquotes in Scala 3 macro throws exception #6038

Closed
yilinwei opened this issue Jan 20, 2024 · 4 comments
Closed

Quasiquotes in Scala 3 macro throws exception #6038

yilinwei opened this issue Jan 20, 2024 · 4 comments

Comments

@yilinwei
Copy link

Describe the bug

Each time I use metals with a particular file with quasiquotes the bloop server dies.

I have pasted the stacktrace from the server.

Expected behavior

The server should not die.

Operating system

Linux

Editor/Extension

Emacs (other)

Version of Metals

1.2.0

Extra context or search terms

Stack trace:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	... 11 more
Caused by: file:///home/yilin/devel/github/Monocle/core/shared/src/main/scala-3/monocle/internal/focus/Compiler.scala:27: error: unclosed character literal
    case '{ (ctx: Focus.KeywordContext) ?=> ${ expr }: (A => B) } => compile(expr)
         ^
	at scala.meta.internal.tokenizers.Reporter.syntaxError(Reporter.scala:23)
	at scala.meta.internal.tokenizers.Reporter.syntaxError$(Reporter.scala:23)
	at scala.meta.internal.tokenizers.Reporter$$anon$1.syntaxError(Reporter.scala:33)
	at scala.meta.internal.tokenizers.Reporter.syntaxError(Reporter.scala:25)
	at scala.meta.internal.tokenizers.Reporter.syntaxError$(Reporter.scala:25)
	at scala.meta.internal.tokenizers.Reporter$$anon$1.syntaxError(Reporter.scala:33)
	at scala.meta.internal.tokenizers.LegacyScanner.fetchSingleQuote$1(LegacyScanner.scala:440)
	at scala.meta.internal.tokenizers.LegacyScanner.fetchToken(LegacyScanner.scala:445)
	at scala.meta.internal.tokenizers.LegacyScanner.nextToken(LegacyScanner.scala:246)
	at scala.meta.internal.mtags.ScalaToplevelMtags.acceptBalancedDelimeters(ScalaToplevelMtags.scala:621)
	at scala.meta.internal.mtags.ScalaToplevelMtags.loop(ScalaToplevelMtags.scala:348)
	at scala.meta.internal.mtags.ScalaToplevelMtags.indexRoot(ScalaToplevelMtags.scala:56)
	at scala.meta.internal.mtags.MtagsIndexer.index(MtagsIndexer.scala:19)
	at scala.meta.internal.mtags.MtagsIndexer.index$(MtagsIndexer.scala:18)
	at scala.meta.internal.mtags.ScalaToplevelMtags.index(ScalaToplevelMtags.scala:43)
	at scala.meta.internal.mtags.Mtags$.allToplevels(Mtags.scala:105)
	at scala.meta.internal.metals.DefinitionProvider.fromMtags(DefinitionProvider.scala:371)
	at scala.meta.internal.metals.DefinitionProvider.$anonfun$positionOccurrence$3(DefinitionProvider.scala:291)
	at scala.Option.orElse(Option.scala:477)
	at scala.meta.internal.metals.DefinitionProvider.$anonfun$positionOccurrence$1(DefinitionProvider.scala:291)
	at scala.Option.flatMap(Option.scala:283)
	at scala.meta.internal.metals.DefinitionProvider.positionOccurrence(DefinitionProvider.scala:286)
	at scala.meta.internal.metals.MetalsLspService.$anonfun$definitionOrReferences$1(MetalsLspService.scala:2388)
	at scala.Option.map(Option.scala:242)
	at scala.meta.internal.metals.MetalsLspService.definitionOrReferences(MetalsLspService.scala:2384)
	at scala.meta.internal.metals.MetalsLspService.$anonfun$definition$1(MetalsLspService.scala:1319)
	at scala.meta.internal.metals.CancelTokens$.future(CancelTokens.scala:38)
	at scala.meta.internal.metals.MetalsLspService.definition(MetalsLspService.scala:1318)
	at scala.meta.internal.metals.WorkspaceLspService.definition(WorkspaceLspService.scala:344)
	at scala.meta.metals.lsp.DelegatingScalaService.definition(DelegatingScalaService.scala:69)
	... 16 more

I originally thought that the scalameta parser might not yet support the grammar, but the current version of scalameta parses the snippet which is causing the error completely fine.

@tgodzik
Copy link
Contributor

tgodzik commented Jan 21, 2024

Thanks for reporting! That is in a Monocle repository? Looks like we may be using a wrong dialect there 🤔

@yilinwei
Copy link
Author

Yes - I checked the root.json and found it didn't have any references to Scala 3. I thought that I had already done a ++ 3 then bloopInstall via sbt a few times - but I think the absence of clang meant that it didn't write the build files properly? Anyway, I added clang to the path and regenerated the build files and the JSON files had the correct references..

Jump to definition still doesn't work for some of the API, but at least the scalameta parser is now happy!

A separate point - is there any way to tell bloop or metals to only care about a very specific cross-build and ignore other modules? I really don't want most of the downstream modules to be compiled while I'm working on the core for example?

@tgodzik
Copy link
Contributor

tgodzik commented Jan 22, 2024

A separate point - is there any way to tell bloop or metals to only care about a very specific cross-build and ignore other modules? I really don't want most of the downstream modules to be compiled while I'm working on the core for example?

The only option currently is to remove the files in .bloop/*.json that you don't care about. There is a discussion about it in #6782

@tgodzik
Copy link
Contributor

tgodzik commented Jan 22, 2024

Jump to definition still doesn't work for some of the API, but at least the scalameta parser is now happy!

Looks like a separate issue, would be good to report that also, but otherwise it seems that the issue is due to the build not importing properly.

I will close that, the feature request is probably good to discuss things at.

@tgodzik tgodzik closed this as not planned Won't fix, can't repro, duplicate, stale Jan 22, 2024
@kasiaMarek kasiaMarek added this to the Metals v1.2.1 milestone Feb 7, 2024
@tgodzik tgodzik moved this to Done in Metals Issue Board Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants