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

Add lint error on importing package within a class #5634

Open
mrstrike007 opened this issue Nov 26, 2024 · 3 comments · May be fixed by #5679
Open

Add lint error on importing package within a class #5634

mrstrike007 opened this issue Nov 26, 2024 · 3 comments · May be fixed by #5679
Labels
area: lint Issue involves SystemVerilog lint checking status: ready Issue is ready for someone to fix; then goes to 'status: assigned'

Comments

@mrstrike007
Copy link

mrstrike007 commented Nov 26, 2024

Section 26.3 of the 2017 LRM states the following "It shall be illegal to have an import statement directly within a class scope.". This fails in Questa/ModelSim with the expected error, yet in Verilator the following code compiles:

`timescale 1ns / 1ps

package pkg;
    typedef enum int {RED, GREEN, BLUE} colors_e_t;
endpackage

class genericClass #(
                     int NUM_INTF = 5
                    );

    import pkg::*;

    colors_e_t colors = RED;

endclass

module tb_top();

    logic tb_clk, tb_rst;

    genericClass #(5) genCls;

    initial begin
        tb_clk = '0;
        tb_rst = '0;

        genCls = new();

        $finish();
    end

endmodule

What 'verilator' command line do we use to run your example?

verilator --top-module tb_top --binary --assert -Wall -Wno-fatal --timescale 1ns/1ps --trace --trace-structs ./tb_top.sv

What 'verilator --version' are you using? Did you try it with the git master version?

Verilator 5.030 2024-10-27 rev v5.030-45-g2cb1a8de7

Have not tried on master head.

What OS and distribution are you using?

Fedora.

May we assist you in trying to fix this in Verilator yourself?

Yes.

@mrstrike007 mrstrike007 added the new New issue not seen by maintainers label Nov 26, 2024
@wsnyder wsnyder added area: lint Issue involves SystemVerilog lint checking status: ready Issue is ready for someone to fix; then goes to 'status: assigned' and removed new New issue not seen by maintainers labels Nov 27, 2024
@wsnyder
Copy link
Member

wsnyder commented Nov 27, 2024

Thanks for the test - a pull to add this error would be appreciated, I'd suggest adding the check in V3LinkParse.

@mrstrike007
Copy link
Author

Just to clarify. Was that suggestion directed at me or to a member?

@wsnyder
Copy link
Member

wsnyder commented Nov 27, 2024

To you, @mrstrike007, as you indicated you might be willing to fix it, thanks for considering!

@wsnyder wsnyder changed the title Importing Package within a Class Does Not Fail Compile Add lint error in importing package within a class Nov 27, 2024
@wsnyder wsnyder changed the title Add lint error in importing package within a class Add lint error on importing package within a class Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: lint Issue involves SystemVerilog lint checking status: ready Issue is ready for someone to fix; then goes to 'status: assigned'
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants