From 43df12ec2c247fe8d5230239f7761d03e840e582 Mon Sep 17 00:00:00 2001 From: Ivano Pagano Date: Sat, 27 Feb 2021 06:58:52 +0100 Subject: [PATCH] Correct the Macros+inline example expansion In the whole macro+inline example, I have a feeling that the `arr` reference inside the spliced `sum` step during expansion, should be quoted. `sum` accepts an Expr in the definition, but at call site `arr` is an Array. --- docs/docs/reference/metaprogramming/macros.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index c439934ff384..dd23041db205 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -560,7 +560,7 @@ then it will splice `sum`: val arr: Array[Int] = Array.apply(1, [2,3 : Int]:Int*) var sum = 0 -${ map(arr, x => '{sum += $x}) } +${ map('arr, x => '{sum += $x}) } sum ``` @@ -571,7 +571,7 @@ val arr: Array[Int] = Array.apply(1, [2,3 : Int]:Int*) var sum = 0 val f = x => '{sum += $x} -${ _root_.Macros.map(arr, 'f)('[Int])} +${ _root_.Macros.map('arr, 'f)('[Int])} sum ```