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

sourcecode.Name does not capture back ticked macro keyword in Scala3 (200USD Bounty) #120

Closed
carueda opened this issue Feb 17, 2022 · 4 comments

Comments

@carueda
Copy link

carueda commented Feb 17, 2022

Scastie: https://scastie.scala-lang.org/carueda/NIAVkP82Rd2RVusUXRZMGQ/13

In short, applying:

def keyword(implicit name: sourcecode.Name): String = name.value

to back ticked macro:

val `macro` = keyword

results in capturing something else, apparently the name of the enclosing environment, but not the val's name itself.

Other Scala keywords seem to be captured just fine.

Haoyi: To incentivize contribution, I'm putting a 200USD bounty on resolving this ticket. This is payable via bank transfer, and at my discretion in case of ambiguity. The acceptance criteria is a PR fixing this issue and updates to our test infrastructure to validate the fix

@carueda
Copy link
Author

carueda commented Aug 3, 2022

though nobody seems to care, fwiw, just reproduced this with Scala 3.1.3 and sourcecode 0.3.0

Screen Shot 2022-08-02 at 8 01 07 PM

java.lang.AssertionError: assertion failed: `macro` == "Playground" not "macro" !
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at Playground$.<clinit>(main.scala:10)
	at Main$.<clinit>(main.scala:15)
	at Main.main(main.scala)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at sbt.Run.invokeMain(Run.scala:143)
	at sbt.Run.execute$1(Run.scala:93)
	at sbt.Run.$anonfun$runWithLoader$5(Run.scala:120)
	at sbt.Run$.executeSuccess(Run.scala:186)
	at sbt.Run.runWithLoader(Run.scala:120)
	at sbt.Run.run(Run.scala:127)
	at com.olegych.scastie.sbtscastie.SbtScastiePlugin$$anon$1.$anonfun$run$1(SbtScastiePlugin.scala:38)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:17)
	at sbt.ScastieTrapExit$App.run(ScastieTrapExit.scala:259)
	at java.base/java.lang.Thread.run(Thread.java:831)

@lihaoyi lihaoyi changed the title sourcecode.Name does not capture back ticked macro keyword in Scala3 sourcecode.Name does not capture back ticked macro keyword in Scala3 (200USD Bounty) May 14, 2024
@KacperFKorban
Copy link
Contributor

Hi, I'd like to take a crack at it

@lihaoyi
Copy link
Member

lihaoyi commented May 14, 2024

@KacperFKorban go for it, no need to ask permission!

lihaoyi pushed a commit that referenced this issue May 21, 2024
Change the synthetic check to use flags and exposed methods instead of
names.

#120
@lihaoyi lihaoyi closed this as completed May 21, 2024
@carueda
Copy link
Author

carueda commented May 22, 2024

awesome.

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

3 participants