Skip to content
/ ziglint Public

Recursion in unused.zig causes infinite loop #24

@F3real

Description

@F3real

Test example bad\unused_decl.zig causes stack overflow due to recursion having infinite loop.

It goes to:

checkNamespace( container_decl_two ...)
→ checkNamespaceItem (fn_decl...)
→ checkNamespaceItem (fn_proto...)
→ searchForNameInNamespace
→ checkValueForName(simple_var_decl...)

where for init node we have container_decl_two
which calls checkNamespace and it repeats.

Can be fixed by just removing:

         .container_decl, .container_decl_trailing => {
             const x = ast.containerDecl(node);
             if (try checkValuesForName(ast, search_name, x.ast.members, writer, file_name, node)) return true;
-            try checkNamespace(ast, node, writer, file_name);
             return false;
         },

But probably larger refactor would be needed to make it more performant/safer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions