MikePopoloski / slang

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

Defaultless parameters cause submodule port/param checks to be skipped #988

Closed AndrewNolte closed 1 month ago

AndrewNolte commented 1 month ago

If the top level has a defaultless parameter, port/param names of submodules are not checked. Test case here: https://github.com/MikePopoloski/slang/pull/987

I'm not sure if this is a feature request or a bug, since top level needs parameters, but I think it would be nice as a linter to find the maximum number of errors given a level of context

MikePopoloski commented 1 month ago

TopModule in your example isn't actually a top-level module. Modules with non-defaulted parameters are never candidates to be top-level modules, so in your example there is simply no top.

It is intentional that uninstantiated modules don't raise errors for missing modules or anything related to parameters in their bodies. People get very annoyed if you report errors for a module they didn't instantiate; sometimes they get pulled into the build for various reasons even though they are unused and they are only intended to be used in a certain configuration / alongside other modules in some other project (i.e. they are some form of library module). For this reason inside uninstantiated modules slang tries hard to only report errors that are guaranteed to be errors no matter what configuration the module may be used in, erring on the side of not reporting if it can't be sure.