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

Action operator with non-lambda argument crashed crashes compilation in scala 3 #356

Open
prolativ opened this issue Apr 1, 2022 · 1 comment
Labels

Comments

@prolativ
Copy link
Contributor

prolativ commented Apr 1, 2022

Trying to compile

//> using scala "3.1.1"
//> using lib "org.parboiled::parboiled:2.4.0"

import org.parboiled2.Parser

trait TestParser { this: Parser => 
  val fun = (x: Int) => x
  def testRule = rule {
    push(1) ~> fun
  }
}

throws an exception

[error] ./parboiled-debug/src/main/scala/org/parboiled/Debug.scala:9:18: Exception occurred while executing macro expansion.
[error] scala.MatchError: Select(This(Ident(TestParser)),fun) (of class dotty.tools.dotc.ast.Trees$Select)
[error]         at org.parboiled2.support.OpTreeContext.org$parboiled2$support$OpTreeContext$$expandLambda(OpTreeContext.scala:412)
[error]         at org.parboiled2.support.OpTreeContext$Action.renderInner(OpTreeContext.scala:419)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.inline$renderInner(OpTreeContext.scala:46)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.render$$anonfun$1(OpTreeContext.scala:39)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.render$$anonfun$adapted$1(OpTreeContext.scala:40)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:81)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1430)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1426)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1410)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.spliceTerms(PickledQuotes.scala:121)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:60)
[error]         at scala.quoted.runtime.impl.QuotesImpl.unpickleExpr(QuotesImpl.scala:2973)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.render(OpTreeContext.scala:40)
[error]         at org.parboiled2.support.OpTreeContext.org$parboiled2$support$OpTreeContext$Sequence$$_$renderInner$$anonfun$1(OpTreeContext.scala:90)
[error]         at scala.collection.immutable.List.map(List.scala:250)
[error]         at scala.collection.immutable.List.map(List.scala:79)
[error]         at org.parboiled2.support.OpTreeContext$Sequence.renderInner(OpTreeContext.scala:90)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.inline$renderInner(OpTreeContext.scala:46)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.render$$anonfun$1(OpTreeContext.scala:39)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.render$$anonfun$adapted$1(OpTreeContext.scala:40)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:81)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1430)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1426)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1410)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.spliceTerms(PickledQuotes.scala:121)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:60)
[error]         at scala.quoted.runtime.impl.QuotesImpl.unpickleExpr(QuotesImpl.scala:2973)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.render(OpTreeContext.scala:40)
[error]         at org.parboiled2.support.OpTreeContext$RuleCall.renderInner(OpTreeContext.scala:538)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.inline$renderInner(OpTreeContext.scala:46)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.render$$anonfun$1(OpTreeContext.scala:39)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.render$$anonfun$adapted$1(OpTreeContext.scala:40)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:81)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1430)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1426)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1410)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.spliceTerms(PickledQuotes.scala:121)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:60)
[error]         at scala.quoted.runtime.impl.QuotesImpl.unpickleExpr(QuotesImpl.scala:2973)
[error]         at org.parboiled2.support.OpTreeContext$NonTerminalOpTree.render(OpTreeContext.scala:40)
[error]         at org.parboiled2.support.OpTreeContext$RuleCall.render(OpTreeContext.scala:533)
[error]         at org.parboiled2.ParserMacros$.nameRuleImpl$$anonfun$2(ParserMacros.scala:139)
[error]         at org.parboiled2.ParserMacros$.nameRuleImpl$$anonfun$adapted$2(ParserMacros.scala:142)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:81)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1430)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1469)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1500)
[error]         at scala.collection.immutable.List.mapConserve(List.scala:472)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1500)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1498)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1410)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.spliceTerms(PickledQuotes.scala:121)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:60)
[error]         at scala.quoted.runtime.impl.QuotesImpl.unpickleExpr(QuotesImpl.scala:2973)
[error]         at org.parboiled2.ParserMacros$.nameRuleImpl(ParserMacros.scala:142)
[error]         at org.parboiled2.ParserMacros$.ruleImpl(ParserMacros.scala:127)
[error]
@jrudolph jrudolph added the Bug label Apr 7, 2022
@jrudolph
Copy link
Collaborator

jrudolph commented Apr 7, 2022

Yes, seems we haven't ported that part of the parser:

case x @ (Ident(_) | Select(_, _)) =>
val valNames = argTypes.indices.map(i => TermName("value" + i)).toList
val args = valNames map Ident.apply
block(popToVals(valNames), q"__push($x(..$args))")

There seem to be no tests for it.

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

No branches or pull requests

2 participants