MikePopoloski / slang

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

using keyword this in class property initialization #889

Closed Maybeka closed 4 months ago

Maybeka commented 4 months ago

Describe the bug slang does not allow using keyword this in class property initialization. But it should be legal.

To Reproduce the code test.sv:

typedef class B;
class A;
  B b;
  function new(B b);
    this.b = b;
  endfunction
endclass

class B;
  A a = new(this);
endclass

module test;
  B b = new();
endmodule

run slang test.sv:

Top level design units:
    test

test.sv:10:13: error: invalid use of 'this' outside of a non-static method
  A a = new(this);
            ^~~~

Build failed: 1 error, 0 warnings
MikePopoloski commented 4 months ago

Fixed in 3ddb9b3c66c18c6c861eedb3ad83dafd108ec9c8