2 Jun 2023 |
davesmith00000#3453 | I'll take a look in the next hour or so. 👍 | 05:49:32 |
Il_totore | I get the right (atleast looks good to me) output with the same code:
inline def addOne = (x: Int) => x + 1
Block(List(DefDef("$anonfun", List(TermParamClause(List(ValDef("x", TypeIdent("Int"), None)))), Inferred(), Some(Apply(Select(Ident("x"), "+"), List(Literal(IntConstant(1))))))) | 06:02:27 |
Il_totore | In 3.3.0 | 06:06:55 |
davesmith00000#3453 | I'm not seeing the same sort of output with Printer.TreeCode that you've got there. | 06:56:22 |
davesmith00000#3453 | I think what's going on in my case is that the inlining is essentially working better now, and it's really inlining everything / discarding unneeded information. What is a minor disaster for me because I was relying on the additional data to reconstruct that fact that this was an anonymous function outside the block the macro is actually operating on. | 06:58:21 |
davesmith00000#3453 | * I think what's going on in my case is that the inlining is essentially working better now, and it's really inlining everything / discarding unneeded information. Which is a minor disaster for me because I was relying on the additional data to reconstruct that fact that this was an anonymous function outside the block the macro is actually operating on. | 06:58:39 |
davesmith00000#3453 | Although the fact that i isn't defined anywhere is just... what is that? It looks like a bug to me but what do I know? | 07:04:05 |
davesmith00000#3453 | Ok, looks like I've stumbled across a workaround. 🎉 | 07:08:52 |
davesmith00000#3453 | If I declare a proxy function (same signature) and just delegate to the outside inlined one, I get the right behaviour. | 07:09:40 |
davesmith00000#3453 | * Ok, looks like I've stumbled across a workaround. 🎉 🤞 | 07:09:59 |
smarter | an Inlined node is what is left after the method call has been inlined | 12:29:32 |
smarter | (it additionally keeps track of the name of the method that was inlined and the position of the method call) | 12:30:18 |
smarter | so the i here refers to something defined in an outer scope | 12:30:26 |
smarter | I don't know what you're trying to achieve, but there's almost surely a better way than inspecting ASTs. | 12:31:08 |
Il_totore | I guess it's related to ultraviolet | 12:50:49 |
Il_totore | * I guess it's related to ultraviolet (their project) | 12:56:40 |
Il_totore | if this is the case, I'm not sure there's another way to achieve this. | 12:57:19 |
Il_totore | but I still don't understand why we don't have the same AST for what seems to be the same code | 12:57:59 |
davesmith00000#3453 | I'd love to read about it somewhere, I'm doing the obvious thing but the documentation on how to do this stuff seems pretty sparse. | 14:05:32 |
davesmith00000#3453 | I expect it's the location of the function that's being inclined. | 14:06:22 |
Il_totore | My entire code is:
//> using scala "3.3.0"
//> using file "LambdaMacro.scala"
println(showExpr:
inline def addOne = (i: Int) => i + 1
)
import scala.quoted.*
inline def showExpr(inline value: Any): String = ${showExprImpl('value)}
def showExprImpl(expr: Expr[Any])(using Quotes): Expr[String] =
import quotes.reflect.*
Expr(expr.asTerm.show(using Printer.TreeStructure)) | 14:10:05 |
Il_totore | Also tested with
//> using scala "3.3.0"
//> using file "LambdaMacro.scala"
inline def addOne = (i: Int) => i + 1
println(showExpr(addOne)) | 14:10:28 |
Il_totore | which still keeps the parameter definition | 14:10:38 |
sandwichwizard#2124 | hey everyone, I'm trying to make sense of an error message around a match type , example in this scastie: https://scastie.scala-lang.org/mrdziuban/vWd7XKzPQVGD8mLChyF0mQ/8
trying to reduce Playground.MergeKV[(("a" : String) ->> Int) *: EmptyTuple, ("b" : String), String]
failed since selector (("a" : String) ->> Int) *: EmptyTuple
does not match case (("b" : String) ->> _) *: t => (("b" : String) ->> String) *: t
and cannot be shown to be disjoint from it either.
Therefore, reduction cannot advance to the remaining cases
case h *: t => h *: Playground.MergeKV[t, ("b" : String), String]
case EmptyTuple => (("b" : String) ->> String) *: EmptyTuple | 15:40:58 |
sandwichwizard#2124 | re: this part in particular
and cannot be shown to be disjoint from it either
am I on the right track in guessing that it can't be shown to be disjoint because both ("a" ->> String) <:< String and ("b" ->> String) <:< String ? | 15:43:12 |
sandwichwizard#2124 | seems like that might be the case...changing type ->>[K, V] to opaque type ->>[K, V] along with an implicit conversion to V does fixes the issue and preserves the behavior I'm hoping it | 16:07:41 |
sandwichwizard#2124 | * seems like that might be the case...changing type ->>[K, V] to opaque type ->>[K, V] along with an implicit conversion to V does fixes the issue and preserves the behavior I'm hoping for | 16:07:45 |
sandwichwizard#2124 | * seems like that might be the case...changing type ->>[K, V] to opaque type ->>[K, V] along with an implicit conversion to V fixes the issue and preserves the behavior I'm hoping for | 16:08:33 |
| bsd changed their display name from bsd to bsd#5601. | 17:42:10 |
| bsd changed their display name from bsd#5601 to bsd. | 17:42:14 |