/******************************************************************************
 * Copyright (c) 2000-2025 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Szabo, Bence Janos
 *
 ******************************************************************************/
module Bug521125 {
//The compiler crashes with fatal error, when attempting to generate code for the attached TTCN-3 module.
//Notify: Parsing TTCN-3 module `DIAMETER_Types.ttcn'...
//Notify: Parsing modules took 0.027209 sec
//Notify: Checking modules...
//Notify: Semantic check took 0.033406 sec
//Notify: Generating code...
//Type.cc:1945: error: Type::get_raw_length()
//Aborted (core dumped)
//Status: fixed, Wrong reference usage
type component EmptyCT {

}

type AVP AVP_list;

type AVP_list AVP_Grouped;

type union Union {
	AVP_Grouped select1,
	integer i
}

type record AVP {
	integer id,
	Union selection
} with {
	variant (selection) "CROSSTAG(
		select1, id = 1;
		i, id = 2
	)"
}

testcase tc_Bug521125() runs on EmptyCT {
	var AVP avp := {
		id := 1,
		selection := {
			select1 := {
				id := 2,
				selection := {
					i := 4
				}
			}
		}
	}

	var bitstring bs := encvalue(avp);
	var AVP result;
	var integer i := decvalue(bs, result);

	if (match(avp, result)) {
		setverdict(pass);
	} else {
		setverdict(fail, match(avp, result));
	}
}

control {
	execute(tc_Bug521125())
}

} with { encode "RAW" }
