From 12980cad3f5a225512ba571f7b9ce02c3c055beb Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Sat, 13 Jul 2024 13:32:08 +0200 Subject: [PATCH] fix: correctly iterate over :publics --- src/iterate.jl | 2 ++ test/iterate/test_iterators.jl | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/iterate.jl b/src/iterate.jl index cb57a9b4..eeec50fa 100644 --- a/src/iterate.jl +++ b/src/iterate.jl @@ -43,6 +43,8 @@ function _getindex(x::EXPR, i) x.args[i] elseif headof(x) === :export oddt_evena(x, i) + elseif headof(x) === :public + oddt_evena(x, i) elseif headof(x) === :filter _filter(x, i) elseif headof(x) === :flatten diff --git a/test/iterate/test_iterators.jl b/test/iterate/test_iterators.jl index 97aa4678..7b108686 100644 --- a/test/iterate/test_iterators.jl +++ b/test/iterate/test_iterators.jl @@ -744,6 +744,21 @@ end @test x[6] === x.args[3] end +if VERSION > v"1.11-" + @testitem ":public" begin + using CSTParser: @cst_str, headof, valof + + x = cst"public a, b, c" + @test length(x) == 6 + @test x[1] === x.trivia[1] + @test x[2] === x.args[1] + @test x[3] === x.trivia[2] + @test x[4] === x.args[2] + @test x[5] === x.trivia[3] + @test x[6] === x.args[3] + end +end + @testitem ":parameters" begin using CSTParser: @cst_str, headof, valof