Illegal declaration after the statement near line '14'. Declarations must precede statements. Look for stray semicolons


import uvm_pkg::*;
`include "uvm_macros.svh"
`include "lab2.svh"

class test_base extends uvm_test;
  `uvm_component_utils(test_base)
  
  function new(string name, uvm_component parent = null);
    super.new(name,parent);
  endfunction:new
  
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    uvm_report_info(get_type_name(),$sformatf("message from build_phase"),UVM_NONE);
	my_subscriber subscriber;
    subscriber = my_subscriber::type_id::create("subscriber");
  endfunction:build_phase
  
  function void connect_phase(uvm_phase phase);
    super.connect_phase(phase);
    uvm_report_info(get_type_name(),$sformatf("message from connect_phase"),UVM_NONE);
  endfunction:connect_phase
  
  function void start_of_simulation_phase(uvm_phase phase);
    super.start_of_simulation_phase(phase);
    uvm_report_info(get_type_name(),$sformatf("message from start_of_simulation_phase"),UVM_NONE);
  endfunction:start_of_simulation_phase
  
  task run_phase(uvm_phase phase);
    #10;
    uvm_report_info(get_type_name(),$sformatf("message from run_phase"),UVM_NONE);
  endtask:run_phase
  
  function void extract_phase(uvm_phase phase);
    super.extract_phase(phase);
    uvm_report_info(get_type_name(),$sformatf("message from extract_phase"),UVM_NONE);
  endfunction:extract_phase
  
  function void check_phase(uvm_phase phase);
    super.check_phase(phase);
    uvm_report_info(get_type_name(),$sformatf("message from check_phase"),UVM_NONE);
  endfunction: check_phase
  
  function void report_phase(uvm_phase phase);
    super.report_phase(phase);
    uvm_report_info(get_type_name(),$sformatf("message from report_phase"),UVM_NONE);
  endfunction:report_phase
  
  
endclass:test_base

I’m getting a Illegal declaration after the statement near line ‘14’. Declarations must precede statements. Look for stray semicolons error. Could someone please help me with regards to what is happening here?

In reply to yr:

Please use code tags when posting code. I have added them for you.

As the error message states, you are declaring the variable ‘subscriber’ after the procedural code uvm_report_info(). All variable declarations must be before procedural code.

In reply to cgales:

got that cgales! Thank you! What exactly do you mean by code tags?

In reply to yr:

https://verificationacademy.com/forums/announcements/please-format-your-code-code-and/code-tags