Skip to content

isvalue yields error for non-chosen field, while it should return false

Summary

According to Section 7.1.8.4, EXAMPLE 3, isvalue should yield false if its parameter is a non-chosen (sub)field of a union. Titan however, returns an error because of the referenced field not being the chosen one.

Steps and/or TTCN-3 code to reproduce

type union MyUnion_isv {
  integer ch1,
  integer ch2
}
template MyUnion_isv mw_myUnion := { ch1 := ? }
type record MyRecord_isv {
  MyUnion_isv u optional
}
template MyRecord_isv mw_myRecord := { u := mw_myUnion }

testcase isvalue_fun() runs on ct_empty{
  var boolean v_checkResult := isvalue(mw_myUnion.ch2); // yields false
  if(not v_checkResult){setverdict(pass);}else{setverdict(fail);}
  v_checkResult := isvalue(mw_myRecord.u.ch2); // yields false
  if(not v_checkResult){setverdict(pass);}else{setverdict(fail);}
  v_checkResult := isvalue(m_myRecord.u.ch2); // yields false
  if(not v_checkResult){setverdict(pass);}else{setverdict(fail);}
}

What is the current bug behavior?

Error.

What is the expected correct behavior?

Pass.

Relevant logs and/or screenshots

../src/operators.ttcn:353.51-53: error: Reference to inactive field `ch2' in a template of union type `@operators.MyUnion_isv'. The active field is `ch1'.

Possible fixes

Titan version

8.1.0

Platform details (OS type and version)

Microsoft Windows 10 Enterprise 10.0.19042

/cc @aknappqwt @mmagyari