Skip to content

Commit f7d6991

Browse files
committed
Convert hex/oct/bin CREFormatException to compile exception
1 parent bc22ff4 commit f7d6991

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/main/java/com/laytonsmith/core/MethodScriptCompiler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,12 @@ public static ParseTree compile(TokenStream stream, Environment environment,
17631763
}
17641764
continue;
17651765
} else if(t.type == TType.LIT) {
1766-
Construct c = Static.resolveConstruct(t.val(), t.target, true);
1766+
Construct c;
1767+
try {
1768+
c = Static.resolveConstruct(t.val(), t.target, true);
1769+
} catch (ConfigRuntimeException ex) {
1770+
throw new ConfigCompileException(ex);
1771+
}
17671772
if((c instanceof CInt || c instanceof CDecimal) && next1.type == TType.DOT && next2.type == TType.LIT) {
17681773
// make CDouble/CDecimal here because otherwise Long.parseLong() will remove
17691774
// minus zero before decimals and leading zeroes after decimals

src/test/java/com/laytonsmith/core/MethodScriptCompilerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.laytonsmith.core.environments.CommandHelperEnvironment;
2121
import com.laytonsmith.core.environments.Environment;
2222
import com.laytonsmith.core.exceptions.AbstractCompileException;
23-
import com.laytonsmith.core.exceptions.CRE.CREFormatException;
2423
import com.laytonsmith.core.exceptions.ConfigCompileException;
2524
import com.laytonsmith.core.exceptions.ConfigCompileGroupException;
2625
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
@@ -1019,7 +1018,7 @@ public void testLiteralDecimal() throws Exception {
10191018
assertEquals("ms.lang.decimal", SRun("typeof(0m1234567890987654321.1234567890987654321)", fakePlayer));
10201019
}
10211020

1022-
@Test(expected = CREFormatException.class)
1021+
@Test(expected = AbstractCompileException.class)
10231022
public void testLiteralBinary() throws Exception {
10241023
SRun("0b2", fakePlayer);
10251024
}

0 commit comments

Comments
 (0)