The core pattern matching example was copy-pasted from this example in the official references.
I have tried to make a minimal no-op macro around the copy-pasted example, which receives nothing and returns a canned expression.
On scala 3.3.1, doing scalac -explain ExprMatch*.scala
, I get the following output:
-- Error: ExprMatchingPlayground.scala:13:28 ---------------------------------------------------------------------------------------------------------------------------------------------------------------
13 | case '{ ((y: Int) => $f(y)).apply($z: Int) } =>
| ^
| Type must be fully defined.
| Consider annotating the splice using a type ascription:
| ($<none>(y): XYZ).
-- [E006] Not Found Error: ExprMatchingPlayground.scala:16:8 -----------------------------------------------------------------------------------------------------------------------------------------------
16 | f(z) // generates '{ 2 + 1 }
| ^
| Not found: f
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| The identifier for `f` is not bound, that is,
| no declaration for this identifier can be found.
| That can happen, for example, if `f` or its declaration has either been
| misspelt or if an import is missing.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- [E006] Not Found Error: ExprMatchingPlayground.scala:16:10 ----------------------------------------------------------------------------------------------------------------------------------------------
16 | f(z) // generates '{ 2 + 1 }
| ^
| Not found: z
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| The identifier for `z` is not bound, that is,
| no declaration for this identifier can be found.
| That can happen, for example, if `z` or its declaration has either been
| misspelt or if an import is missing.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 errors found
Just to confirm whether this previously worked, I also tried compiling with 3.0.0, and I get essentially the same output:
-- Error: ExprMatchingPlayground.scala:13:27 ---------------------------------------------------------------------------------------------------------------------------------------------------------------
13 | case '{ ((y: Int) => $f(y)).apply($z: Int) } =>
| ^^
| Type must be fully defined.
-- [E006] Not Found Error: ExprMatchingPlayground.scala:16:8 -----------------------------------------------------------------------------------------------------------------------------------------------
16 | f(z) // generates '{ 2 + 1 }
| ^
| Not found: f
Explanation
===========
The identifier for `f` is not bound, that is,
no declaration for this identifier can be found.
That can happen, for example, if `f` or its declaration has either been
misspelt or if an import is missing.
-- [E006] Not Found Error: ExprMatchingPlayground.scala:16:10 ----------------------------------------------------------------------------------------------------------------------------------------------
16 | f(z) // generates '{ 2 + 1 }
| ^
| Not found: z
Explanation
===========
The identifier for `z` is not bound, that is,
no declaration for this identifier can be found.
That can happen, for example, if `z` or its declaration has either been
misspelt or if an import is missing.
3 errors found
See also stack overflow question https://stackoverflow.com/questions/77718835/why-does-this-scala-3-macros-reference-example-of-hoas-fail-with-type-must-be-f?r=SearchResults