File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,11 @@ compilerify-macro = (env, func) ->
107
107
108
108
return switch
109
109
| internal -ast -form is null => null
110
- | typeof ! internal -ast -form is \Array => env .compile-many internal -ast -form
110
+ | typeof ! internal -ast -form is \Array =>
111
+ internal -ast -form .for -each ->
112
+ if not it ?
113
+ throw Error "Multi-returning macro return array contained `#it`"
114
+ env .compile-many internal -ast -form
111
115
| otherwise =>
112
116
113
117
sm -ast = env .compile internal -ast -form
Original file line number Diff line number Diff line change @@ -1007,6 +1007,21 @@ test "invalid AST returned by macro throws error" ->
1007
1007
'''
1008
1008
Error
1009
1009
1010
+ test " macro multi -returning array with bad values throws descriptive error " ->
1011
+ try
1012
+ # `console.log` is invalid as a variable name, but if used as if it were
1013
+ # one, without checking if the AST makes sense, this will compile to
1014
+ # valid JavaScript code of `console.log('hi');`!
1015
+ esl '''
1016
+ (macro breaking (function () (return ((. this multi) " hi " null))))
1017
+ (breaking)
1018
+ '''
1019
+ catch e
1020
+ e.message `@equals` " Multi -returning macro return array contained `null `"
1021
+ return
1022
+
1023
+ @fail!
1024
+
1010
1025
test " macro return intermediates may be invalid if fixed by later macro " ->
1011
1026
# `...` is an invalid variable name, but since it's corrected by a later
1012
1027
# macro before evaluation, that's fine.
You can’t perform that action at this time.
0 commit comments