Repository navigation
Conversation
|
pkg.pr.new packages benchmark commit |
Bundle size comparison (
|
| 🟢 Decreased (max -12.36%) | ➖ Unchanged | 🔴 Increased (max 1.26%) | ❔ Unknown |
|---|---|---|---|
| 1 | 38 | 316 | 0 |
import * as ... in PR vs import * as ... in target (did bundle size increase?):
Click to reveal the results table (306 entries).
| Test | tsdown |
|---|---|
| d_bool.ts | 20.29 kB ( |
| d_f16.ts | 20.29 kB ( |
| d_f32.ts | 20.29 kB ( |
| d_i32.ts | 20.29 kB ( |
| d_u32.ts | 20.29 kB ( |
| d_ref.ts | 20.30 kB ( |
| d_u16.ts | 20.31 kB ( |
| d_abstractInt.ts | 20.37 kB ( |
| d_abstractFloat.ts | 20.37 kB ( |
| d_textureDepth2d.ts | 20.74 kB ( |
| d_textureDepthCube.ts | 20.74 kB ( |
| d_texture1d.ts | 20.75 kB ( |
| d_texture2d.ts | 20.75 kB ( |
| d_texture3d.ts | 20.75 kB ( |
| d_textureCube.ts | 20.75 kB ( |
| d_textureDepth2dArray.ts | 20.75 kB ( |
| d_textureDepthCubeArray.ts | 20.76 kB ( |
| d_textureDepthMultisampled2d.ts | 20.76 kB ( |
| d_texture2dArray.ts | 20.76 kB ( |
| d_textureCubeArray.ts | 20.77 kB ( |
| d_textureMultisampled2d.ts | 20.77 kB ( |
| std_isKnownAtComptime.ts | 20.91 kB ( |
| std_subgroupElect.ts | 21.48 kB ( |
| std_subgroupAll.ts | 21.49 kB ( |
| std_subgroupAny.ts | 21.49 kB ( |
| std_quadSwapX.ts | 21.49 kB ( |
| std_quadSwapY.ts | 21.49 kB ( |
| std_subgroupOr.ts | 21.49 kB ( |
| std_subgroupAdd.ts | 21.49 kB ( |
| std_subgroupAnd.ts | 21.49 kB ( |
| std_subgroupMax.ts | 21.49 kB ( |
| std_subgroupMin.ts | 21.49 kB ( |
| std_subgroupMul.ts | 21.49 kB ( |
| std_subgroupXor.ts | 21.49 kB ( |
| std_quadSwapDiagonal.ts | 21.50 kB ( |
| std_subgroupExclusiveAdd.ts | 21.51 kB ( |
| std_subgroupExclusiveMul.ts | 21.51 kB ( |
| std_subgroupInclusiveAdd.ts | 21.51 kB ( |
| std_subgroupInclusiveMul.ts | 21.51 kB ( |
| std_subgroupBroadcastFirst.ts | 21.51 kB ( |
| std_storageBarrier.ts | 21.53 kB ( |
| std_textureBarrier.ts | 21.53 kB ( |
| std_workgroupBarrier.ts | 21.54 kB ( |
| std_discard.ts | 21.55 kB ( |
| std_textureNumLayers.ts | 21.56 kB ( |
| std_textureNumLevels.ts | 21.56 kB ( |
| std_textureNumSamples.ts | 21.57 kB ( |
| std_textureSampleCompare.ts | 21.59 kB ( |
| std_textureSampleCompareLevel.ts | 21.61 kB ( |
| std_textureStore.ts | 21.61 kB ( |
| std_workgroupUniformLoad.ts | 21.63 kB ( |
| tgpu_comptime.ts | 21.65 kB ( |
| std_atomicLoad.ts | 21.67 kB ( |
| std_atomicOr.ts | 21.71 kB ( |
| std_atomicAdd.ts | 21.71 kB ( |
| std_atomicAnd.ts | 21.71 kB ( |
| std_atomicMax.ts | 21.71 kB ( |
| std_atomicMin.ts | 21.71 kB ( |
| std_atomicSub.ts | 21.71 kB ( |
| std_atomicXor.ts | 21.71 kB ( |
| std_atomicExchange.ts | 21.72 kB ( |
| std_atomicStore.ts | 21.76 kB ( |
| std_quadBroadcast.ts | 21.76 kB ( |
| std_arrayLength.ts | 21.76 kB ( |
| std_subgroupShuffleUp.ts | 21.76 kB ( |
| std_subgroupShuffle.ts | 21.76 kB ( |
| std_subgroupShuffleXor.ts | 21.76 kB ( |
| std_subgroupShuffleDown.ts | 21.77 kB ( |
| std_subgroupBroadcast.ts | 21.77 kB ( |
| std_copy.ts | 21.79 kB ( |
| std_extensionEnabled.ts | 21.86 kB ( |
| std_range.ts | 22.13 kB ( |
| std_isBeingTranspiled.ts | 22.17 kB ( |
| std_getShaderStage.ts | 22.23 kB ( |
| std_getTargetShaderLanguage.ts | 22.24 kB ( |
| std_typeOf.ts | 22.28 kB ( |
| d_disarrayOf.ts | 22.35 kB ( |
| d_deepEqual.ts | 23.00 kB ( |
| d_schemasEqualNominally.ts | 23.00 kB ( |
| d_schemasEqualStructurally.ts | 23.00 kB ( |
| std_atomicCompareExchangeWeak.ts | 24.31 kB ( |
| tgpu_computeFn.ts | 46.64 kB ( |
| tgpu_vertexFn.ts | 47.19 kB ( |
| tgpu_fragmentFn.ts | 47.37 kB ( |
| tgpu_fn.ts | 47.49 kB ( |
| common_fullScreenTriangle.ts | 49.19 kB ( |
| std_subgroupBallot.ts | 27.96 kB ( |
| std_textureSampleBaseClampToEdge.ts | 28.05 kB ( |
| std_textureSampleGrad.ts | 28.06 kB ( |
| std_textureSampleBias.ts | 28.11 kB ( |
| std_textureSample.ts | 28.13 kB ( |
| std_textureSampleLevel.ts | 28.14 kB ( |
| std_textureGatherCompare.ts | 28.18 kB ( |
| std_textureDimensions.ts | 28.20 kB ( |
| d_uint8.ts | 28.25 kB ( |
| d_float16.ts | 28.25 kB ( |
| d_float16x2.ts | 28.25 kB ( |
| d_float16x4.ts | 28.25 kB ( |
| d_float32.ts | 28.25 kB ( |
| d_float32x2.ts | 28.25 kB ( |
| d_float32x3.ts | 28.25 kB ( |
| d_float32x4.ts | 28.25 kB ( |
| d_sint16.ts | 28.25 kB ( |
| d_sint16x2.ts | 28.25 kB ( |
| d_sint16x4.ts | 28.25 kB ( |
| d_sint32.ts | 28.25 kB ( |
| d_sint32x2.ts | 28.25 kB ( |
| d_sint32x3.ts | 28.25 kB ( |
| d_sint32x4.ts | 28.25 kB ( |
| d_sint8.ts | 28.25 kB ( |
| d_sint8x2.ts | 28.25 kB ( |
| d_sint8x4.ts | 28.25 kB ( |
| d_snorm16.ts | 28.25 kB ( |
| d_snorm16x2.ts | 28.25 kB ( |
| d_snorm16x4.ts | 28.25 kB ( |
| d_snorm8.ts | 28.25 kB ( |
| d_snorm8x2.ts | 28.25 kB ( |
| d_snorm8x4.ts | 28.25 kB ( |
| d_uint16.ts | 28.25 kB ( |
| d_uint16x2.ts | 28.25 kB ( |
| d_uint16x4.ts | 28.25 kB ( |
| d_uint32.ts | 28.25 kB ( |
| d_uint32x2.ts | 28.25 kB ( |
| d_uint32x3.ts | 28.25 kB ( |
| d_uint32x4.ts | 28.25 kB ( |
| d_uint8x2.ts | 28.25 kB ( |
| d_uint8x4.ts | 28.25 kB ( |
| d_unorm10_10_10_2.ts | 28.25 kB ( |
| d_unorm16.ts | 28.25 kB ( |
| d_unorm16x2.ts | 28.25 kB ( |
| d_unorm16x4.ts | 28.25 kB ( |
| d_unorm8.ts | 28.25 kB ( |
| d_unorm8x2.ts | 28.25 kB ( |
| d_unorm8x4.ts | 28.25 kB ( |
| d_unorm8x4_bgra.ts | 28.25 kB ( |
| d_formatToWGSLType.ts | 28.25 kB ( |
| std_textureGather.ts | 28.37 kB ( |
| d_packedFormats.ts | 28.27 kB ( |
| d_isPackedData.ts | 28.32 kB ( |
| std_textureLoad.ts | 29.99 kB ( |
| d_alignmentOf.ts | 30.11 kB ( |
| std_bitcast.ts | 30.77 kB ( |
| STATIC_common.ts | 56.74 kB ( |
| std_pack2x16float.ts | 31.78 kB ( |
| std_unpack2x16unorm.ts | 31.78 kB ( |
| std_unpack2x16float.ts | 31.79 kB ( |
| std_pack4xI8.ts | 31.80 kB ( |
| std_unpack4xI8.ts | 31.80 kB ( |
| std_pack4xU8.ts | 31.80 kB ( |
| std_unpack4xU8.ts | 31.80 kB ( |
| std_unpack2x16snorm.ts | 31.81 kB ( |
| std_unpack4x8unorm.ts | 31.83 kB ( |
| std_unpack4x8snorm.ts | 31.87 kB ( |
| std_pack2x16snorm.ts | 31.96 kB ( |
| std_pack2x16unorm.ts | 31.96 kB ( |
| std_pack4xU8Clamp.ts | 31.97 kB ( |
| std_pack4xI8Clamp.ts | 31.98 kB ( |
| std_pack4x8snorm.ts | 32.04 kB ( |
| std_pack4x8unorm.ts | 32.04 kB ( |
| d_sizeOf.ts | 32.90 kB ( |
| d_isContiguous.ts | 32.91 kB ( |
| d_getLongestContiguousPrefix.ts | 32.92 kB ( |
| d_isBuiltin.ts | 33.00 kB ( |
| d_arrayOf.ts | 33.79 kB ( |
| std_identity2.ts | 34.46 kB ( |
| std_identity3.ts | 34.46 kB ( |
| std_identity4.ts | 34.46 kB ( |
| std_rotationX4.ts | 34.46 kB ( |
| std_rotationY4.ts | 34.46 kB ( |
| std_rotationZ4.ts | 34.46 kB ( |
| std_scaling4.ts | 34.46 kB ( |
| std_translation4.ts | 34.46 kB ( |
| d_matToArray.ts | 34.60 kB ( |
| d_size.ts | 34.66 kB ( |
| d_align.ts | 34.66 kB ( |
| d_location.ts | 34.67 kB ( |
| d_interpolate.ts | 34.67 kB ( |
| tgpu_vertexLayout.ts | 34.93 kB ( |
| d_invariant.ts | 35.04 kB ( |
| common_writeSoA.ts | 35.52 kB ( |
| std_dot4I8Packed.ts | 35.85 kB ( |
| std_dot4U8Packed.ts | 35.85 kB ( |
| std_firstLeadingBit.ts | 35.86 kB ( |
| std_determinant.ts | 35.94 kB ( |
| std_dpdxFine.ts | 35.94 kB ( |
| std_dpdyFine.ts | 35.94 kB ( |
| std_dpdxCoarse.ts | 35.94 kB ( |
| std_dpdyCoarse.ts | 35.94 kB ( |
| std_fwidthFine.ts | 35.94 kB ( |
| std_dpdx.ts | 35.94 kB ( |
| std_dpdy.ts | 35.94 kB ( |
| std_fwidthCoarse.ts | 35.94 kB ( |
| std_fwidth.ts | 35.95 kB ( |
| std_refract.ts | 35.95 kB ( |
| std_trunc.ts | 36.00 kB ( |
| std_reverseBits.ts | 36.01 kB ( |
| std_quantizeToF16.ts | 36.01 kB ( |
| std_countOneBits.ts | 36.01 kB ( |
| std_extractBits.ts | 36.02 kB ( |
| std_firstTrailingBit.ts | 36.02 kB ( |
| std_countLeadingZeros.ts | 36.03 kB ( |
| std_countTrailingZeros.ts | 36.03 kB ( |
| std_insertBits.ts | 36.03 kB ( |
| std_faceForward.ts | 36.03 kB ( |
| std_intdiv.ts | 36.04 kB ( |
| std_tan.ts | 36.08 kB ( |
| std_degrees.ts | 36.09 kB ( |
| std_radians.ts | 36.09 kB ( |
| std_inverseSqrt.ts | 36.12 kB ( |
| std_round.ts | 36.13 kB ( |
| std_step.ts | 36.26 kB ( |
| std_ldexp.ts | 36.26 kB ( |
| std_fma.ts | 36.27 kB ( |
| std_transpose.ts | 36.33 kB ( |
| d_builtin.ts | 36.31 kB ( |
| std_not.ts | 36.49 kB ( |
| d_memoryLayoutOf.ts | 36.49 kB ( |
| std_abs.ts | 36.50 kB ( |
| std_neg.ts | 36.55 kB ( |
| std_or.ts | 36.56 kB ( |
| std_and.ts | 36.64 kB ( |
| std_lt.ts | 36.65 kB ( |
| std_eq.ts | 36.65 kB ( |
| std_cos.ts | 36.67 kB ( |
| std_exp.ts | 36.67 kB ( |
| std_log.ts | 36.67 kB ( |
| std_sin.ts | 36.67 kB ( |
| std_exp2.ts | 36.67 kB ( |
| std_sign.ts | 36.67 kB ( |
| std_acos.ts | 36.67 kB ( |
| std_asin.ts | 36.67 kB ( |
| std_atan.ts | 36.67 kB ( |
| std_ceil.ts | 36.67 kB ( |
| std_cosh.ts | 36.67 kB ( |
| std_log2.ts | 36.67 kB ( |
| std_sinh.ts | 36.67 kB ( |
| std_sqrt.ts | 36.67 kB ( |
| std_tanh.ts | 36.67 kB ( |
| std_acosh.ts | 36.68 kB ( |
| std_asinh.ts | 36.68 kB ( |
| std_atanh.ts | 36.68 kB ( |
| std_floor.ts | 36.68 kB ( |
| std_fract.ts | 36.68 kB ( |
| std_ge.ts | 36.71 kB ( |
| std_ne.ts | 36.72 kB ( |
| std_gt.ts | 36.87 kB ( |
| std_le.ts | 36.79 kB ( |
| std_saturate.ts | 36.82 kB ( |
| std_pow.ts | 36.85 kB ( |
| std_atan2.ts | 36.86 kB ( |
| std_clamp.ts | 36.95 kB ( |
| tgpu_accessor.ts | 68.40 kB ( |
| std_max.ts | 36.97 kB ( |
| std_min.ts | 36.97 kB ( |
| tgpu_mutableAccessor.ts | 68.40 kB ( |
| std_smoothstep.ts | 37.07 kB ( |
| std_mix.ts | 37.22 kB ( |
| std_mod.ts | 37.50 kB ( |
| std_div.ts | 37.55 kB ( |
| std_select.ts | 37.47 kB ( |
| std_add.ts | 37.62 kB ( |
| tgpu_resolveWithContext.ts | 161.49 kB ( |
| tgpu_resolve.ts | 161.56 kB ( |
| std_frexp.ts | 38.58 kB ( |
| std_modf.ts | 38.71 kB ( |
| std_bitShiftLeft.ts | 39.81 kB ( |
| std_bitShiftRight.ts | 39.81 kB ( |
| std_all.ts | 39.82 kB ( |
| std_length.ts | 40.20 kB ( |
| std_dot.ts | 40.10 kB ( |
| std_cross.ts | 40.31 kB ( |
| std_any.ts | 40.64 kB ( |
| std_allEq.ts | 40.85 kB ( |
| std_isCloseTo.ts | 41.13 kB ( |
| std_normalize.ts | 41.22 kB ( |
| std_bitcastF32toU32.ts | 42.01 kB ( |
| std_bitcastU32toF32.ts | 42.01 kB ( |
| std_bitcastU32toI32.ts | 42.01 kB ( |
| std_mul.ts | 42.24 kB ( |
| std_rotateZ4.ts | 42.50 kB ( |
| std_translate4.ts | 42.50 kB ( |
| std_scale4.ts | 42.50 kB ( |
| std_rotateX4.ts | 42.51 kB ( |
| std_rotateY4.ts | 42.51 kB ( |
| std_sub.ts | 42.62 kB ( |
| std_reflect.ts | 43.30 kB ( |
| std_distance.ts | 43.39 kB ( |
| d_mat4x4f.ts | 47.76 kB ( |
| d_vec2b.ts | 47.76 kB ( |
| d_vec2u.ts | 47.76 kB ( |
| d_vec3b.ts | 47.76 kB ( |
| d_vec3f.ts | 47.76 kB ( |
| d_vec3u.ts | 47.76 kB ( |
| d_vec4b.ts | 47.76 kB ( |
| d_vec4u.ts | 47.76 kB ( |
| d_mat2x2f.ts | 47.76 kB ( |
| d_mat3x3f.ts | 47.76 kB ( |
| d_vec2h.ts | 47.76 kB ( |
| d_vec3h.ts | 47.76 kB ( |
| d_vec4h.ts | 47.76 kB ( |
| d_vec3i.ts | 47.76 kB ( |
| d_vec4f.ts | 47.76 kB ( |
| d_vec4i.ts | 47.76 kB ( |
| d_vec2f.ts | 47.76 kB ( |
| d_vec2i.ts | 47.76 kB ( |
| STATIC_useGpuFunction.ts | 227 B ( |
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [1.11, 2.34, 5.05, 7.55, 9.04, 13.30, 28.84, 30.15]
line [1.10, 2.25, 5.07, 7.29, 9.24, 14.81, 27.56, 29.33]
line [1.14, 2.21, 4.68, 7.47, 8.34, 13.56, 27.59, 29.63]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.37, 0.58, 0.77, 0.93, 1.24, 1.37, 1.61, 1.75]
line [0.32, 0.61, 0.75, 0.90, 1.31, 1.31, 1.64, 1.76]
line [0.33, 0.60, 0.77, 0.97, 1.23, 1.30, 1.56, 1.73]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [1.02, 2.32, 4.32, 8.50, 15.32, 29.24, 65.11, 131.86]
line [1.23, 2.65, 4.77, 9.76, 15.79, 30.08, 63.57, 125.92]
line [1.13, 2.42, 4.01, 8.15, 14.90, 30.95, 63.17, 127.38]
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for simple object destructuring inside 'use gpu' functions by extending the Tinyest AST to represent variable bindings as a BindingPattern (identifier vs. destructured object), then updating parsing, WGSL generation, linting, obfuscation, and tests accordingly.
Changes:
- Extend Tinyest
let/constdeclarations to useBindingPatternand introduceBindingPatternType(with compatibility aliases for existingFuncParameter*naming). - Parse simple object destructuring for variable declarations / parameters in
tinyest-for-wgsl, and generate corresponding WGSL declarations inWgslGenerator. - Update ESLint rule coverage and test snapshots across packages to reflect the new AST shape and supported destructuring subset.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/unplugin-typegpu/test/use-gpu-directive.test.ts | Updates expected Tinyest AST snapshots for let/const bindings. |
| packages/unplugin-typegpu/test/tgsl-transpiling.test.ts | Updates transpilation snapshots to the new binding pattern representation. |
| packages/unplugin-typegpu/test/parser-options.test.ts | Adjusts parser option snapshot to the new BindingPattern form. |
| packages/unplugin-typegpu/test/obfuscation.test.ts | Adds coverage for obfuscating destructured variable declarations + updates snapshots. |
| packages/unplugin-typegpu/test/aliasing.test.ts | Updates alias-gathering snapshots to new binding representation. |
| packages/unplugin-typegpu/src/core/obfuscate.ts | Refactors binding obfuscation to support identifier vs destructured object patterns. |
| packages/typegpu/tests/tgsl/wgslGenerator.test.ts | Adds WGSL generator tests for object destructuring (const/let, single-eval, name conflicts). |
| packages/typegpu/tests/internal/tseynit.test.ts | Adds stringify coverage for destructured binding declarations. |
| packages/typegpu/tests/internal/metadata.test.ts | Updates metadata normalization tests to handle legacy vs new binding forms. |
| packages/typegpu/src/tgsl/wgslGenerator.ts | Implements object destructuring statement lowering and updates let/const handling to BindingPattern. |
| packages/typegpu/src/shared/tseynit.ts | Adds BindingPattern stringification for debugging/printing. |
| packages/typegpu/src/shared/normalizeMetadata.ts | Normalizes legacy metadata by converting string bindings into identifier BindingPatterns. |
| packages/typegpu/src/resolutionCtx.ts | Updates parameter pattern checks to use BindingPatternType. |
| packages/tinyest/src/nodes.ts | Introduces BindingPatternType/BindingPattern, updates Let/Const to use them, keeps compatibility aliases. |
| packages/tinyest-for-wgsl/tests/parsers.test.ts | Adds parser coverage for destructured declarations and unsupported patterns + snapshot updates. |
| packages/tinyest-for-wgsl/src/parsers.ts | Adds parsing for BindingPattern (identifier/object destructuring), rejects unsupported destructuring contexts. |
| packages/eslint-plugin/tests/rules/noUnsupportedSyntax.test.ts | Expands valid/invalid coverage for supported destructuring + unsupported binding patterns / loop headers. |
| packages/eslint-plugin/src/rules/noUnsupportedSyntax.ts | Allows supported simple object binding patterns, adds checks for destructuring assignment and loop-header destructuring. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
✅ No outstanding changes needed.
Reviewed changes
- tinyest
Let/Constbinding overhaul — The 2nd tuple element changed from astringto a structuredBindingPattern(identifier/destructuredObject);FuncParameter/FuncParameterTypekept as aliases of the new names for backward source compatibility, and every consumer of the shared node shape was updated in lockstep. - TGSL parser (
tinyest-for-wgsl) — NewparseBindingPattern(shared by variable declarations and function parameters) replaces the previous per-parameter inline mapping, and now hard-rejects nested/computed/default/rest/array patterns, destructuring assignments, and destructuring infor-loop init /for...ofheaders with clear errors. - WGSL lowering (
wgslGenerator) —_objectDestructuringStatementlowers a destructured const/let into an internal temporary (guaranteeing single evaluation of the source expression) plus one const/let per alias; temporary names are uniquified via the existingmakeUniqueIdentifiermachinery, and mutable destructuredletcorrectly lowers tovar. The GLSL generator inherits the same lowering. - Metadata migration (
normalizeMetadata) —normalizeLegacyBindingsrecursively rewrites legacy v1/v2 metadata where a let/const binding was a plain string into the new identifierBindingPatternshape, and is idempotent on the new object form; the internal metadata tests exercise real end-to-end resolve on legacy-shaped metadata as well as the new format. - ESLint rule (
noUnsupportedSyntax) — Now allows simple object-pattern variable declarations and destructured parameters while rejecting everything else; its support predicate matches what the parser accepts, so lint and transpile stay in agreement. - Obfuscation (
obfuscate.ts) —obfuscateBindingPatternrenames identifier bindings and destructured aliases while leaving property names intact (they must survive into the generated member access). - Tests across the parser, generator, metadata migration, obfuscation, and eslint rule layers, including single-evaluation, name-collision, and mutation cases.
⚠️ Pre-existing silent-drop now fails loudly (improvement, but a behavior change)
On the old code path, destructured function-parameter sub-properties that weren't the simple key: alias shape were silently dropped (props.flatMap((prop) => condition ? [entry] : [])), which could route an argument into the wrong struct field — a correctness bug. The new parseBindingPattern throws for these. That hard error is strictly better and the eslint rule now reports it earlier with a helpful message, but it is a behavioral change for any code that previously transpiled-but-mishandled such params — worth a line in the changelog/release notes.
I verified the changed packages independently: all targeted unit tests pass (tinyest-for-wgsl parsers, unplugin obfuscation, typegpu wgslGenerator/metadata/tseynit, eslint noUnsupportedSyntax) and the core typegpu typecheck (pnpm --filter typegpu test:types) is clean.
ℹ️ Nitpicks
wgslGenerator.#destructuringIndexis an instance-global counter that is never reset, so temporary names are numbered monotonically across every function in a resolve rather than per function. Harmless (each name is further uniquified in its own scope) but slightly inconsistent with how other names are scoped.- The generated temporary for a non-identifier destructing source is emitted as a mutable
let(struct values take the deferred var-type path even though the temp is never reassigned). Cosmetic;constcould be used, but there's no behavioral impact.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
d0a6a3d to
6d9418f
Compare
|
Run failed. View the logs →
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Single evaluation of external destructuring sources — a dotted external access such as
source.valuereaches_objectDestructuringStatementas a string, so the previous code generated one property read per alias by re-resolving the source each time. The source expression is now resolved once and cached in block externals under#destructured_source, so a JS getter fires once per declaration. - Regression test for the above — new
reads an external object getter once per destructuring declarationcase pins both the JS read count and the folded WGSL constants; verified it fails against the pre-fix branch (reads all advance:y=2, a=3, b=4). - Prior-review cleanup — removed the never-reset
#destructuringIndexcounter and switched the temp primer to a fixed#destructured, sanitized and uniquified bymakeUniqueIdentifier; snapshots updated accordingly. - Collision coverage refreshed — the name-conflict test now covers an external function named
destructuredplus a user identifierdestructured_1, and the stale parser snapshot was corrected to the new binding-pattern shape.
ℹ️ Plain-identifier sources are exercised only indirectly
The new test drives the else branch through a dotted external (source.value), but the more common const pair = Pair(...); const { a, b: c } = pair; form from the PR description also routes through that branch and has no test pinning its output.
Technical details
# Missing coverage for the bare-identifier source path
## Affected sites
- `packages/typegpu/src/tgsl/wgslGenerator.ts:1344` — the `else` branch in `_objectDestructuringStatement`.
- `packages/typegpu/tests/tgsl/wgslGenerator.test.ts:2059` — `destructures an identifier without a temporary` actually passes a constructor call (`Pair({...})`), so it exercises the temp branch despite its name.
## Required outcome
- A test that destructures a previously declared local identifier and asserts the emitted `let a = pair.a; let c = pair.b;` with no temporary.
## Open questions for the human
- Is the mismatch between the test name at line 2059 and its body intentional, or was a bare-identifier case meant to live there?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- ESLint rule consolidated into one
ObjectPatternvisitor — Object-pattern logic no longer lives across several visitors. The new visitor reports by default and allows a pattern only when it is a block-level declaration (VariableDeclarator→VariableDeclaration→BlockStatement) or a direct parameter of the enclosing'use gpu'function, and the pattern has the supported simple shape. The previous loop-header special case and the inline parameter sub-pattern check are gone, so a newly supported destination must be registered explicitly or CI flags it. - Function-parameter validation extracted — A shared
validateFunctionParametershelper is called from the arrow, function-expression, and function-declaration visitors; it still permitsIdentifier/AssignmentPattern/ObjectPatternand reports array/rest/other patterns asunsupported function parameter binding pattern. - Messages unified and coverage expanded — Destructuring assignments, nested/computed/default/rest patterns, and loop-header destructuring all now report
object destructuring; tests add thelet, nested-block, all-three-function-forms-with-destructured-params,for-header, assignment, and array/rest-param cases. The fulleslint-pluginsuite passes (146 tests).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
cbdfdb6 to
d7af0a3
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review, the branch was rebased onto current main (absorbing the tinyest-for-wgsl parser split from #2932 and computed object-property support from #2950) and adds one authorial commit, d7af0a3d3:
- Empty destructuring no longer forces a block scope —
_objectDestructuringStatementnow derivesdefinesInNearestScopefrom whether any generated declaration actually emits code.const {} = source;(identifier source: no temp, no aliases) produces nothing, so the enclosing block inlines instead of introducing braces; a function-call source still emits thelet destructured = ...temp, so evaluation and scoping are retained. for...oferror message normalized — the destructuring guard in thefor...ofpath no longer saysfor..of.- Two regression tests in
wgslGenerator.test.ts— one pins inlining of empty destructuring of an identifier, the other pins that empty destructuring of a call keeps the temp and the block.
I verified the new tests pass at head, and confirmed the first one fails against the pre-fix definesInNearestScope: true (the block braces reappear in the snapshot), so it is real coverage rather than a tautology.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| }; | ||
|
|
||
| export type FuncParameter = BindingPattern; | ||
| export const FuncParameterType = BindingPatternType; |
There was a problem hiding this comment.
Good idea with merging these two types, but I don't think we can do that just yet.
I'm not sure what our policy on non-backwards-compatible changes in tinyest is, it would probably be best to ask @iwoplaza, but I think that it would be fine to update FuncParameter to either be as it is now, or BindingPattern (updated to be for example Identifier | [name: number, alias?: number][]), and then drop the original type in a couple of versions and bump the metadata version.
Actually, not related to this PR, RawMetadataV1 depending on tinyest may not have been the greatest idea, tinyest updates may change what we think RawMetadataV1 is... Can you depend on multiple versions of the same package?
There was a problem hiding this comment.
I think that this might be a pretty common usage. Also, it will probably require non-tirvial new infrastructure, so I think that this should be delegated to another PR. Could you create an issue for that?
it('allows for destructuring bind group layouts', () => {
const layout = tgpu.bindGroupLayout({
buf: { uniform: d.u32 },
});
const fn = () => {
'use gpu';
const { buf } = layout.$;
};
expect(tgpu.resolve([fn])).toMatchInlineSnapshot();
});d7af0a3 to
ff4dc2b
Compare
ff4dc2b to
fcde66a
Compare

Adds #2318
Allows simple object destructuring like:
or
which generates:
and
This PR introduces a breaking change for
FuncParametersintinyest-for-wgsl:In
tinyest,FuncParameteraccepts both legacy parameters andBindingPatternduring the transition.typegpunormalizes legacy metadata, but users oftinyest-for-wgslparser need to handle the new representation