Skip to content

nimsuggest use command does not return all instances of symbol #12832

Closed
@onelivesleft

Description

This is not a problem in nimsuggest itself, but rather an issue in sem.nim or one of it's variants not adding the symbols to the graph. This seems to affect symbols inside templates.

Example:

import macros

let
    options_type_label         = "options_type_label_string"
    options_instance_label     = "options_instance_label_string"
    proc_label                 = "proc_label_string"
    supplied_instance_label    = "supplied_instance_label_string"

macro config*(body: untyped): untyped =
    let options_root_node =
        nnk_var_section.new_tree(
            nnk_ident_defs.new_tree(
                ident(options_instance_label),
                new_empty_node(),
                nnk_obj_constr.new_tree(
                    ident(options_type_label)
                )))
    var options_node = options_root_node[0][2]

    let call_node =
        nnk_call.new_tree(
            ident(proc_label),
            ident(options_instance_label),
            ident(supplied_instance_label))

    template add_field_value_offset(name: string) =
        assignments_node.add(
            nnk_call.new_tree(
                nnk_dot_expr.new_tree(
                    ident(field_offsets_label),
                    ident("add")),
                nnk_infix.new_tree(
                    ident("-"),
                    nnk_cast.new_tree(
                        ident("uint"),
                        nnk_command.new_tree(
                            ident("addr"),
                            nnk_dot_expr.new_tree(
                                ident(options_instance_label),
                                ident(name)))),
                    nnk_cast.new_tree(
                        ident("uint"),
                        nnk_command.new_tree(
                            ident("addr"),
                            ident(options_instance_label))))))

Given the above file, a nimsuggest use looking for options_instance_label will find the first three appearances, but not the last two (inside the template)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions