Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Warning reported regarding unused generic procedures/functions #298

Open
nselvara opened this issue Apr 27, 2024 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@nselvara
Copy link

nselvara commented Apr 27, 2024

Hi guys, I get this warning when I use generic functions/procedures:
Unused declaration of procedure check_equal_generic[type_t, type_t, STRING, log_level_t, NATURAL, NATURAL, STRING]vhdl ls(unused)

I get the reason behind why it's flagged as not used but I think it should only emit this warning when it hasn't been defined with a generic map.

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

library vunit_lib;
context vunit_lib.vunit_context;

library osvvm;
use osvvm.NamePkg.NamePType;

package pkg_test is
    type test_t is (test_1, test_2, test_3);

    procedure check_equal_generic
        generic (
            type type_t;
            function to_string(data: type_t) return NamePType
        )
        parameter (
            got: in type_t;
            expected: in type_t;
            msg: in string := check_result_tag;
            level: in log_level_t := null_log_level;
            path_offset: in natural := 1;
            line_num: in natural := 0;
            file_name: in string := ""
        );

    procedure check_equal is new check_equal_generic generic map (data_t => test_t);
end package;

package body pkg_test is
    function to_string(data: test_t) return NamePType is
        variable result: NamePType;    
    begin
        case data is
            when test_1 => result.Set("test_1");
            when test_2 => result.Set("test_2");
            when test_3 => result.Set("test_3");
        end case;
        return result;
    end function;

    procedure check_equal_generic
        generic (
            type type_t;
            function to_string(data: type_t) return NamePType
        )
        parameter (
            got: in type_t;
            expected: in type_t;
            msg: in string := check_result_tag;
            level: in log_level_t := null_log_level;
            path_offset: in natural := 1;
            line_num: in natural := 0;
            file_name: in string := ""
        ) is
        constant checker: checker_t := default_checker;
    begin
        -- pragma translate_off
        if got = expected then
            if is_pass_visible(checker) then
                passing_check(
                    checker,
                    p_std_msg(
                        "Equality check passed", msg,
                        "Got " & to_string(got).Get & "."
                    ),
                    path_offset + 1, line_num, file_name
                );
            else
                passing_check(checker);
            end if;
        else
            failing_check(
                checker,
                p_std_msg(
                    "Equality check failed", msg,
                    "Got " & to_string(got).Get & ". " &
                    "Expected " & to_string(expected).Get & "."
                ),
                level, path_offset + 1, line_num, file_name
            );
        end if;
    end;
end package body;
@Schottkyc137 Schottkyc137 added the bug Something isn't working label Apr 28, 2024
@Schottkyc137
Copy link
Contributor

Can confirm. Here's a shorter MRE

package pkg_test is
    procedure foo
        generic (type type_t)
        parameter (bar: type_t);

    procedure baz is new foo generic map (type_t => natural);
end package;

package body pkg_test is
    procedure foo
        generic (type type_t)
        parameter (bar: type_t)
    is begin
    end;
end package body;

The actual problem is that the information that the foo procedure implementation is linked to the foo procedure specification is not generated correctly at the moment (reference : https://github.com/VHDL-LS/rust_hdl/blob/master/vhdl_lang/src/analysis/subprogram.rs#L424).

@nselvara
Copy link
Author

Hihi, yes the shorter one is more preferable to analyse. 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants