MikePopoloski / slang

SystemVerilog compiler and language services
MIT License
558 stars 122 forks source link

slang-tidy does not find functions from different files. #990

Closed Andful closed 1 month ago

Andful commented 1 month ago

Describe the bug When running slang-tidy, it does not find functions from different files.

To Reproduce Consider the following code snippet.

function automatic integer unsigned min(integer unsigned x, integer unsigned y);
    return (x < y) ? x : y; 
endfunction

module top;
initial begin
    $display("%d", min(1,2));
end
endmodule

If I run slang-tidy on the code in its entirety within a file, slang-tidy does not complain. If I put top in top.sv and min in min.sv and run either:

$ slang-tidy min.sv top.sv

or

$ slang-tidy top.sv min.sv

slang-tidy complains with:

top.v:3:20: error: use of undeclared identifier 'min'
    $display("%d", min(1,2));
                   ^~~
slang-tidy: errors found during compilation

Additional context Tested it on v6.0 ( commit 7bcff26 ), with a self-compiled alpine docker image. The docker image can be run with:

$ docker run --rm -it -v `pwd`:/workdir ghcr.io/andful/pipelined-math:master

Not sure if it is intended behavior, but it differs in behavior from iverilog.

Andful commented 1 month ago

The same behavior seem to occur with slang .

MikePopoloski commented 1 month ago

By default each file is considered its own compilation unit. If you would like them to be concatenated together you can use --single-unit. See: https://sv-lang.com/user-manual.html#compilation-units

Andful commented 1 month ago

Ah thanks!