From 3f3a5da3a906d19ebc4e1b7bceee4bac739df07b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 23 Oct 2021 23:27:31 +0100 Subject: [PATCH] mantis 6199 and 6872: Yengine will now error at compile tme if state name not found. Was doing it at runtime only. Xengine stays as it was --- .../ScriptEngine/YEngine/MMRScriptCodeGen.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs index 54aafa5476..a35dcdc34d 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs @@ -2485,17 +2485,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine int index = 0; // 'default' state - // Set new state value by throwing an exception. - // These exceptions aren't catchable by script-level try { } catch { }. - if((stateStmt.state != null) && !stateIndices.TryGetValue(stateStmt.state.val, out index)) + // Set new state value by throwing an exception. + // These exceptions aren't catchable by script-level try { } catch { }. + if ((stateStmt.state != null) && !stateIndices.TryGetValue(stateStmt.state.val, out index)) { - // The moron XEngine compiles scripts that reference undefined states. - // So rather than produce a compile-time error, we'll throw an exception at runtime. - // ErrorMsg (stateStmt, "undefined state " + stateStmt.state.val); + mightGetHere = false; + // do compile time error + ErrorMsg (stateStmt, "undefined state " + stateStmt.state.val); + throw new Exception("undefined state " + stateStmt.state.val); - // throw new UndefinedStateException (stateStmt.state.val); - ilGen.Emit(stateStmt, OpCodes.Ldstr, stateStmt.state.val); - ilGen.Emit(stateStmt, OpCodes.Newobj, scriptUndefinedStateExceptionConstructorInfo); + // before we did throw an exception only at runtime. + //ilGen.Emit(stateStmt, OpCodes.Ldstr, stateStmt.state.val); + //ilGen.Emit(stateStmt, OpCodes.Newobj, scriptUndefinedStateExceptionConstructorInfo); } else {