# Set\_type\_override not valid while no compile error

**URL:** <https://verificationacademy.com/forums/t/set-type-override-not-valid-while-no-compile-error/30188>\
**Category:** UVM\
**Tags:** UVM, set\_type\_override\_by\_type\
**Created:** [December 1, 2014, 9:43am UTC](https://verificationacademy.com/forums/t/set-type-override-not-valid-while-no-compile-error/30188 "2014-12-01T09:43:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mission89](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/3d9bf3/32.png) [@mission89](https://verificationacademy.com/forums/u/mission89)\
**Post date:** [December 1, 2014, 9:43am UTC](https://verificationacademy.com/forums/t/set-type-override-not-valid-while-no-compile-error/30188/1 "2014-12-01T09:43:41Z")

</div>

class A extends uvm\_sequence\_item;  
`uvm\_object\_utils(A);  
…  
endclass

class B extends A;  
// no uvm\_object\_utils(B)  
add some new constraint …  
endclass

I use: set\_type\_override\_by\_type(A::get\_type(), B::get\_type());  
The compile log show: uvm\_warning: original type and override type are identical.  
Ques1: Is it because I have’t reigster B that results in set\_type\_overrid not take effect?  
Ques2: If i did’t register B, why set\_type\_override has no compile error, while only a compile warning?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [December 1, 2014, 8:59pm UTC](https://verificationacademy.com/forums/t/set-type-override-not-valid-while-no-compile-error/30188/2 "2014-12-01T20:59:42Z")

</div>

From the SystemVerilog perspective, the code is perfectly legal and would not generate a compiler error. One of the pitfalls of using macros is that you do not see the underlying code generated by the macro. I recommend learning the UVM without using any macros and introduce them later as you begin to understand what the macros are doing. See my [blog post](https://blogs.sw.siemens.com/verificationhorizons/2011/02/13/parameterized-classes-static-members-and-the-factory-macros/) and this [cookbook article](https://verificationacademy.com/cookbook/macrocostbenefit) to get a better understanding.

The reason B::get\_type() does not generate a compiler error is because the `uvm\_object\_utils(A) macro declares A::get\_Type for you, and since class B is an extension of class A, B inherits get\_type() from A. So both of your arguments to set\_type\_override() call the same function. I’ts not until sumulation run time that the UVM checks that the two functions return a handle to the same wrapper object.

IMHO, it would be better to make these kinds of messages a UVM\_ERROR by default. You can do that with the following statement:

```verilog
      uvm_top.set_report_severity_id_override(UVM_WARNING,"TYPDUP",UVM_ERROR);

```

---

<div class="post-metadata">

**Author:** ![mission89](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/3d9bf3/32.png) [@mission89](https://verificationacademy.com/forums/u/mission89)\
**Post date:** [December 2, 2014, 1:22am UTC](https://verificationacademy.com/forums/t/set-type-override-not-valid-while-no-compile-error/30188/3 "2014-12-02T01:22:00Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/set-type-override-not-valid-while-no-compile-error/30188/2):_

Dear dave,  
Thanks for your detailed answer. I get it
