|
246 | 246 | @oldstyle_non_Expr |
247 | 247 | """) === 42 |
248 | 248 |
|
| 249 | +@testset "calling with old/new macro signatures" begin |
| 250 | + # Old defined with 1 arg, new with 2 args, both with 3 (but with different values) |
| 251 | + Base.eval(test_mod, :(macro sig_mismatch(x); x; end)) |
| 252 | + Base.eval(test_mod, :(macro sig_mismatch(x, y, z); z; end)) |
| 253 | + JuliaLowering.include_string(test_mod, "macro sig_mismatch(x, y); x; end") |
| 254 | + JuliaLowering.include_string(test_mod, "macro sig_mismatch(x, y, z); x; end") |
| 255 | + |
| 256 | + @test JuliaLowering.include_string(test_mod, "@sig_mismatch(1)") === 1 |
| 257 | + @test JuliaLowering.include_string(test_mod, "@sig_mismatch(1, 2)") === 1 |
| 258 | + @test JuliaLowering.include_string(test_mod, "@sig_mismatch(1, 2, 3)") === 1 # 3 if we prioritize old sig |
| 259 | + err = try |
| 260 | + JuliaLowering.include_string(test_mod, "@sig_mismatch(1, 2, 3, 4)") === 1 |
| 261 | + catch exc |
| 262 | + sprint(showerror, exc) |
| 263 | + end |
| 264 | + @test startswith(err, """ |
| 265 | + MacroExpansionError while expanding @sig_mismatch in module Main.macros.test_mod: |
| 266 | + @sig_mismatch(1, 2, 3, 4) |
| 267 | + └───────────────────────┘ ── Error expanding macro |
| 268 | + Caused by: |
| 269 | + MethodError: no method matching var"@sig_mismatch"(::LineNumberNode, ::Module, ::Int64, ::Int64, ::Int64, ::Int64) |
| 270 | + """) |
| 271 | +end |
249 | 272 | end # module macros |
0 commit comments