diff --git a/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts b/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts index e61b437760..622c2d7f9b 100644 --- a/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts +++ b/buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts @@ -38,6 +38,12 @@ java { repositories { mavenCentral() + mavenLocal { + content { + includeModule("org.squiddev", "Cobalt") + } + } + val mainMaven = maven("https://squiddev.cc/maven") { name = "SquidDev" content { @@ -57,7 +63,6 @@ repositories { filter { includeGroup("cc.tweaked") - includeModule("org.squiddev", "Cobalt") // Things we mirror includeGroup("commoble.morered") includeGroup("dev.architectury") diff --git a/gradle.properties b/gradle.properties index dfa227cb4c..23fbfbebe6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ kotlin.jvm.target.validation.mode=error # Mod properties isUnstable=false -modVersion=1.108.3 +modVersion=1.109.0-SNAPSHOT # Minecraft properties: We want to configure this here so we can read it in settings.gradle mcVersion=1.20.1 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index db44bf33b4..d633bd1633 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,8 +19,8 @@ parchmentMc = "1.20.1" asm = "9.5" autoService = "1.1.1" checkerFramework = "3.32.0" -cobalt = "0.7.3" -cobalt-next = "0.7.4" # Not a real version, used to constrain the version we accept. +cobalt = "0.8.0-SNAPSHOT" +cobalt-next = "0.8.1" # Not a real version, used to constrain the version we accept. fastutil = "8.5.9" guava = "31.1-jre" jetbrainsAnnotations = "24.0.1" diff --git a/projects/core/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java b/projects/core/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java index 3510c89560..ade0cf4d6a 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java +++ b/projects/core/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java @@ -73,20 +73,20 @@ public CobaltLuaMachine(MachineEnvironment environment, InputStream bios) throws .build(); // Set up our global table. - var globals = state.getMainThread().getfenv(); - CoreLibraries.debugGlobals(state); - Bit32Lib.add(state, globals); - globals.rawset("_HOST", ValueFactory.valueOf(environment.hostString())); - globals.rawset("_CC_DEFAULT_SETTINGS", ValueFactory.valueOf(CoreConfig.defaultComputerSettings)); + try { + var globals = state.globals(); + CoreLibraries.debugGlobals(state); + Bit32Lib.add(state, globals); + globals.rawset("_HOST", ValueFactory.valueOf(environment.hostString())); + globals.rawset("_CC_DEFAULT_SETTINGS", ValueFactory.valueOf(CoreConfig.defaultComputerSettings)); - // Add default APIs - for (var api : environment.apis()) addAPI(globals, api); + // Add default APIs + for (var api : environment.apis()) addAPI(globals, api); - // And load the BIOS - try { + // And load the BIOS var value = LoadState.load(state, bios, "@bios.lua", globals); - mainRoutine = new LuaThread(state, value, globals); - } catch (CompileException e) { + mainRoutine = new LuaThread(state, value); + } catch (LuaError | CompileException e) { throw new MachineException(Nullability.assertNonNull(e.getMessage())); } @@ -171,7 +171,7 @@ private LuaTable wrapLuaObject(Object object) { return found ? table : null; } - private LuaValue toValue(@Nullable Object object, @Nullable IdentityHashMap values) { + private LuaValue toValue(@Nullable Object object, @Nullable IdentityHashMap values) throws LuaError { if (object == null) return Constants.NIL; if (object instanceof Number num) return ValueFactory.valueOf(num.doubleValue()); if (object instanceof Boolean bool) return ValueFactory.valueOf(bool); @@ -235,7 +235,7 @@ private LuaValue toValue(@Nullable Object object, @Nullable IdentityHashMap queue = new ArrayDeque<>(); try (InputStream stream = new FileInputStream(file)) { - var proto = LuaC.compile(stream, "@" + file.getPath()); + var proto = LuaC.compile(new LuaState(), stream, "@" + file.getPath()); queue.add(proto); - } catch (CompileException e) { + } catch (LuaError | CompileException e) { throw new IllegalStateException("Cannot compile", e); } diff --git a/projects/core/src/test/java/dan200/computercraft/core/lua/VarargArgumentsTest.java b/projects/core/src/test/java/dan200/computercraft/core/lua/VarargArgumentsTest.java index 97a6aa36c2..5c4da7722f 100644 --- a/projects/core/src/test/java/dan200/computercraft/core/lua/VarargArgumentsTest.java +++ b/projects/core/src/test/java/dan200/computercraft/core/lua/VarargArgumentsTest.java @@ -7,6 +7,7 @@ import dan200.computercraft.api.lua.LuaException; import org.junit.jupiter.api.Test; import org.squiddev.cobalt.Constants; +import org.squiddev.cobalt.LuaError; import org.squiddev.cobalt.LuaTable; import org.squiddev.cobalt.ValueFactory; @@ -18,7 +19,11 @@ class VarargArgumentsTest { private static LuaTable tableWithCustomType() { var metatable = new LuaTable(); - metatable.rawset(Constants.NAME, ValueFactory.valueOf("some type")); + try { + metatable.rawset(Constants.NAME, ValueFactory.valueOf("some type")); + } catch (LuaError e) { + throw new IllegalStateException("Cannot create metatable", e); + } var table = new LuaTable(); table.setMetatable(null, metatable); diff --git a/projects/core/src/test/resources/test-rom/spec/base_spec.lua b/projects/core/src/test/resources/test-rom/spec/base_spec.lua index fe37fb6530..5ea044f371 100644 --- a/projects/core/src/test/resources/test-rom/spec/base_spec.lua +++ b/projects/core/src/test/resources/test-rom/spec/base_spec.lua @@ -79,20 +79,6 @@ describe("The Lua base library", function() end) describe("load", function() - it("validates arguments", function() - load("") - load(function() - end) - load("", "") - load("", "", "") - load("", "", "", _ENV) - - expect.error(load, nil):eq("bad argument #1 (function or string expected, got nil)") - expect.error(load, "", false):eq("bad argument #2 (string expected, got boolean)") - expect.error(load, "", "", false):eq("bad argument #3 (string expected, got boolean)") - expect.error(load, "", "", "", false):eq("bad argument #4 (table expected, got boolean)") - end) - local function generator(parts) return coroutine.wrap(function() for i = 1, #parts do diff --git a/projects/core/src/test/resources/test-rom/spec/programs/shell_spec.lua b/projects/core/src/test/resources/test-rom/spec/programs/shell_spec.lua index 92e19172a4..bdd4ed99ca 100644 --- a/projects/core/src/test/resources/test-rom/spec/programs/shell_spec.lua +++ b/projects/core/src/test/resources/test-rom/spec/programs/shell_spec.lua @@ -214,7 +214,7 @@ describe("The shell", function() local lines = {} for i = 1, 5 do lines[i] = win.getLine(i):gsub(" +$", "") end expect(lines):same { - "CraftOS 1.8", + "CraftOS 1.9", "> xyz", "Transferring transfer.txt", "> xyz",