From 7c03cc516a93eeef890e0bb4fa1fff822bdebb99 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 20 Oct 2025 14:29:43 -0400 Subject: [PATCH] Fix playground --- src/playground_wasm/main.zig | 47 +++----------------- test/serialization_size_check.zig | 2 +- test/snapshots/fuzz_crash/fuzz_crash_027.md | 1 + test/snapshots/fuzz_crash/fuzz_crash_049.md | Bin 115141 -> 115187 bytes test/snapshots/plume_package/Color.md | 1 + test/snapshots/type_app_complex_nested.md | 2 + test/snapshots/type_app_multiple_args.md | 1 + test/snapshots/type_comprehensive_scope.md | 1 + 8 files changed, 12 insertions(+), 43 deletions(-) diff --git a/src/playground_wasm/main.zig b/src/playground_wasm/main.zig index 4bf7ab1e80..b50bf4e26d 100644 --- a/src/playground_wasm/main.zig +++ b/src/playground_wasm/main.zig @@ -942,48 +942,11 @@ fn compileSource(source: []const u8) !CompilerStageData { const base_ptr = @intFromPtr(buffer.ptr); logDebug("loadCompiledModule: About to deserialize common\n", .{}); - const deserialized_common = serialized_ptr.common.deserialize(@as(i64, @intCast(base_ptr)), module_source).*; - logDebug("loadCompiledModule: common deserialized successfully\n", .{}); - - logDebug("loadCompiledModule: About to deserialize types\n", .{}); - const deserialized_types = serialized_ptr.types.deserialize(@as(i64, @intCast(base_ptr)), gpa).*; - logDebug("loadCompiledModule: types deserialized successfully\n", .{}); - - logDebug("loadCompiledModule: About to deserialize external_decls\n", .{}); - const deserialized_external_decls = serialized_ptr.external_decls.deserialize(@as(i64, @intCast(base_ptr))).*; - logDebug("loadCompiledModule: external_decls deserialized successfully\n", .{}); - - logDebug("loadCompiledModule: About to deserialize imports\n", .{}); - const deserialized_imports = serialized_ptr.imports.deserialize(@as(i64, @intCast(base_ptr)), gpa).*; - logDebug("loadCompiledModule: imports deserialized successfully\n", .{}); - - logDebug("loadCompiledModule: About to deserialize store\n", .{}); - const deserialized_store_ptr = serialized_ptr.store.deserialize(@as(i64, @intCast(base_ptr)), gpa); - const deserialized_store = deserialized_store_ptr.*; - logDebug("loadCompiledModule: store deserialized successfully\n", .{}); - - // Intern the module name for fast comparisons - const module_name_idx = module_env_ptr.common.idents.insert(gpa, base.Ident.for_text(module_name_param)) catch unreachable; - - logDebug("loadCompiledModule: All deserialized, constructing ModuleEnv\n", .{}); - module_env_ptr.* = ModuleEnv{ - .gpa = gpa, - .common = deserialized_common, - .types = deserialized_types, - .module_kind = serialized_ptr.module_kind, - .all_defs = serialized_ptr.all_defs, - .all_statements = serialized_ptr.all_statements, - .exports = serialized_ptr.exports, - .builtin_statements = serialized_ptr.builtin_statements, - .external_decls = deserialized_external_decls, - .imports = deserialized_imports, - .module_name = module_name_param, - .module_name_idx = module_name_idx, - .diagnostics = serialized_ptr.diagnostics, - .store = deserialized_store, - .evaluation_order = null, - }; - logDebug("loadCompiledModule: ModuleEnv constructed successfully\n", .{}); + // Use the built-in deserialize method instead of manually deserializing each field + // This ensures proper offset calculations when the struct layout changes + logDebug("loadCompiledModule: About to deserialize ModuleEnv\n", .{}); + module_env_ptr.* = serialized_ptr.deserialize(@as(i64, @intCast(base_ptr)), gpa, module_source, module_name_param).*; + logDebug("loadCompiledModule: ModuleEnv deserialized successfully\n", .{}); logDebug("loadCompiledModule: Returning LoadedModule\n", .{}); return .{ .env = module_env_ptr, .buffer = buffer, .gpa = gpa }; diff --git a/test/serialization_size_check.zig b/test/serialization_size_check.zig index 22c164be00..b95ac65c32 100644 --- a/test/serialization_size_check.zig +++ b/test/serialization_size_check.zig @@ -31,7 +31,7 @@ const expected_safelist_u8_size = 24; const expected_safelist_u32_size = 24; const expected_safemultilist_teststruct_size = 24; const expected_safemultilist_node_size = 24; -const expected_moduleenv_size = 604; // Platform-independent size +const expected_moduleenv_size = 608; // Platform-independent size const expected_nodestore_size = 96; // Platform-independent size // Compile-time assertions - build will fail if sizes don't match expected values diff --git a/test/snapshots/fuzz_crash/fuzz_crash_027.md b/test/snapshots/fuzz_crash/fuzz_crash_027.md index e7f2c17046..54602ca848 100644 --- a/test/snapshots/fuzz_crash/fuzz_crash_027.md +++ b/test/snapshots/fuzz_crash/fuzz_crash_027.md @@ -228,6 +228,7 @@ TOO FEW ARGS - fuzz_crash_027.md:21:3:22:4 INVALID IF CONDITION - fuzz_crash_027.md:50:5:50:5 INCOMPATIBLE MATCH PATTERNS - fuzz_crash_027.md:64:2:64:2 TYPE MISMATCH - fuzz_crash_027.md:111:2:113:3 +TYPE MISMATCH - fuzz_crash_027.md:143:2:147:3 # PROBLEMS **LEADING ZERO** Numbers cannot have leading zeros. diff --git a/test/snapshots/fuzz_crash/fuzz_crash_049.md b/test/snapshots/fuzz_crash/fuzz_crash_049.md index e967a7cb15801f465ce0db095d955a42c479c42b..2b6657a9dc69a001e4344beb336bc541b5ca9149 100644 GIT binary patch delta 47 zcmX@w%>KEVeM6}^Z%AZ-tAej*u&-l?v&ZC#++tjY=2nJQhCtG+xx{>Xi8*6n7XW!s B4!-~Z delta 42 wcmey|%zm_)eM6}^m$E`YkiV0Ut8eh;gBIe9lNBs?0C7z74a@B}EE%Oc08Tm&iU0rr diff --git a/test/snapshots/plume_package/Color.md b/test/snapshots/plume_package/Color.md index 24d1590ab7..1d135c2708 100644 --- a/test/snapshots/plume_package/Color.md +++ b/test/snapshots/plume_package/Color.md @@ -81,6 +81,7 @@ is_named_color = |str|{ MODULE HEADER DEPRECATED - Color.md:1:1:8:2 UNUSED VARIABLE - Color.md:30:5:30:25 DOES NOT EXIST - Color.md:68:14:68:27 +TYPE MISMATCH - Color.md:32:5:45:6 TYPE MISMATCH - Color.md:51:104:51:105 # PROBLEMS **MODULE HEADER DEPRECATED** diff --git a/test/snapshots/type_app_complex_nested.md b/test/snapshots/type_app_complex_nested.md index 9b95c81845..20feff930b 100644 --- a/test/snapshots/type_app_complex_nested.md +++ b/test/snapshots/type_app_complex_nested.md @@ -33,6 +33,8 @@ UNDECLARED TYPE - type_app_complex_nested.md:4:30:4:35 UNDECLARED TYPE - type_app_complex_nested.md:4:51:4:56 UNUSED VARIABLE - type_app_complex_nested.md:7:12:7:21 UNDECLARED TYPE - type_app_complex_nested.md:12:14:12:19 +TOO MANY ARGS - type_app_complex_nested.md:18:44:18:63 +TOO MANY ARGS - type_app_complex_nested.md:4:41:4:61 # PROBLEMS **UNDECLARED TYPE** The type _Maybe_ is not declared in this scope. diff --git a/test/snapshots/type_app_multiple_args.md b/test/snapshots/type_app_multiple_args.md index 42300a7ab9..f52482823d 100644 --- a/test/snapshots/type_app_multiple_args.md +++ b/test/snapshots/type_app_multiple_args.md @@ -14,6 +14,7 @@ main! = |_| processDict(Dict.empty().insert("one", 1)) ~~~ # EXPECTED DOES NOT EXIST - type_app_multiple_args.md:6:25:6:35 +TOO MANY ARGS - type_app_multiple_args.md:3:15:3:29 # PROBLEMS **DOES NOT EXIST** `Dict.empty` does not exist. diff --git a/test/snapshots/type_comprehensive_scope.md b/test/snapshots/type_comprehensive_scope.md index 76966039e1..ee6fd727c3 100644 --- a/test/snapshots/type_comprehensive_scope.md +++ b/test/snapshots/type_comprehensive_scope.md @@ -47,6 +47,7 @@ TYPE REDECLARED - type_comprehensive_scope.md:10:1:10:37 UNDECLARED TYPE - type_comprehensive_scope.md:13:19:13:23 TYPE REDECLARED - type_comprehensive_scope.md:22:1:22:13 UNDECLARED TYPE - type_comprehensive_scope.md:25:11:25:29 +TOO MANY ARGS - type_comprehensive_scope.md:29:10:29:24 # PROBLEMS **TYPE REDECLARED** The type _Result_ is being redeclared.