MikePopoloski / slang

SystemVerilog compiler and language services
MIT License
546 stars 114 forks source link

Function name used as variable causes error in VCS compatibility mode #976

Closed hankhsu1996 closed 3 weeks ago

hankhsu1996 commented 3 weeks ago

Describe the bug In compatibility mode with VCS, using the slang compiler throws an error when a function name is used as a variable within the function's own scope. This behavior differs from VCS, where no error is thrown.

To Reproduce Steps to reproduce the behavior:

  1. Create a SystemVerilog file test.sv with the following content:

    module my_mod;
    function automatic logic my_func();
    my_func = 1'b1;
    assert (my_func === 1'b1)
      else $error("Expect my_func to return 1 but got %0b", my_func);
    endfunction
    endmodule
  2. Compile the file using slang in VCS compatibility mode with the command:

    slang test.sv --compat vcs
  3. Observe the following error:

    error: parentheses are required when invoking function 'my_func'
      else $error("Expect my_func to return 1 but got %0b", my_func);
                                                            ^~~~~~~

Additional context In normal mode (without --compat vcs), it can pass without error.

MikePopoloski commented 3 weeks ago

Fixed in 42dfd0ca3be747ea5e85c8e33e0a3d8f7591776e