MikePopoloski / slang

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

Output of exists() method for associative arrays not treated as int type? #909

Closed jrudess closed 3 months ago

jrudess commented 3 months ago

I was expecting -Wint-bool-conv to flag a warning for this example. LRM section is 7.9.3. All the other built-in methods that return int type do appear to be flagged by the warning.

class C;
    bit m[string];

    function f();
        if (m.exists("test")) begin
        end
    endfunction

endclass
jrudess commented 3 months ago

Read through the code in ArrayMethods.cpp and it looks like this is intentional behavior (i.e. getEffectiveWidth returns 1).

MikePopoloski commented 3 months ago

Yeah, a warning here seems to serve no purpose but to annoy people, since the result is essentially Boolean.