Usage of Ast.full.FnProto.iterate?

I try using Ast for parsing a Zig source code to generate a different Zig source (for context: I’m trying to generate a wrapper for Raylib for my toy language Moin).

I started with adapting Ast.Render, but the code for looping through the args of a function is a bit complicated, so I looked for a cleaner way. The iterate function returns an Iteratorfor the arguments. This works in some cases, but in other cases it panics, because the ast.params slice just contains a single zero.

Is this a bug?

Anyone else here used the Ast for metaprogramming and stumbled over this?

Not sure if that’s the reason, because I changed a lot, but today I saw that I stored the FnProto data for later use. This is not valid, however, because the ast.params attribute is a slice with a short lifetime. I’m not using iterate anymore, but I had other issues which vanished after dupeing the prams slice for later use.