Problem with uvm_registry

Hi All
I encounter an error ( Error TMAFTC Too many arguments to function/task call) when compile the following code



`include "uvm_macros.svh"
module test; // not work

  import uvm_pkg::*;
  
  class env extends uvm_env;
    `uvm_component_utils(env)
    function new(string name = "env");
      super.new(name);
      $display("HELLO",);
    endfunction
    
    
    task run_phase(uvm_phase phase);
      phase.raise_objection(this);
      #1000;
      phase.drop_objection(this);
    endtask
    
  endclass

  
  initial begin
    run_test("env");

  end

endmodule 

But if i change to this, it works.



`include "uvm_macros.svh"
module test; // it works

  import uvm_pkg::*;
  
  class env extends uvm_env;
    
    function new(string name = "env");
      super.new(name);
      $display("HELLO",);
    endfunction
    
    
    task run_phase(uvm_phase phase);
      phase.raise_objection(this);
      #1000;
      phase.drop_objection(this);
    endtask
    
  endclass
  

    env e;
  
  initial begin
    e = new();
    run_test();

  end

endmodule 

I don’t know why i use uvm_component_utils and run_test(“env”),then it will happen compile error.
would you explain it to me ? Thanks a lot!!

In reply to peter:

Classes derived from uvm_component have two arguments; a name and a parent. Your class env constructor only has one argument, so the default null gets used, but the `uvm_component_utils macro inserts code that tries to pass two arguments to your constructor.

You need to make sure the constructor of all classes derived from uvm_component have two arguments.

In reply to dave_59:

Thanks for reply! As for another version , I used new to construct env instead of using factory. why run_test (without input argument) can start uvm_phase?

In reply to peter:

The code inserted by `uvm_component_utils must compile whether you decide to use it or not.

run_test() requires the construction of at least one uvm_component object. You can explicitly construct it before calling run_test as your examples does, or it can be constructed by the factory using the string name provided the argument to run_test(), or by the string from the +UVM_TESTNAME argument.