Rust codegen internal local bindings shadow TypeScript parameter names
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 70/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust, typescript
- 領域
- backend
調査の方向性
Start by reading the four named generators: RustProxyGenerator.swift, RustCallbackGenerator.swift, RustModuleGenerator.swift, and RustFunctionGenerator.swift, and trace how internal bindings are emitted alongside TypeScript parameters. Check the generated Rust for methods using the listed conflicting parameter names and run the relevant compiler tests. Done means generated bindings use reserved internal names and those cases compile and pass their tests.
索引モデルが issue の本文から書いたものです。
説明
Found while reviewing https://github.com/Snapchat/Valdi/pull/211 (native Rust code generation). Not blocking that PR.
Unprefixed internal bindings in RustProxyGenerator collide with TypeScript parameter names
File: compiler/compiler/Compiler/Sources/Generation/Rust/RustProxyGenerator.swift
When a TypeScript @ExportProxy method has a parameter named function_value, function, or marshaller (or arguments/proxy in invoke), the generated Rust method fails to compile or silently passes the wrong value. RustProxyGenerator.write() binds local variables function_value, function, and closure parameter marshaller in borrowedMethods, and arguments/proxy in invokeCases, using unprefixed names.
Any TypeScript parameter with the same snake-case name is shadowed inside the generated body, causing FunctionRef::call_with or ValdiPush::push_to to reference the local FunctionRef/Marshaller instead of the argument. (The same unprefixed internal bindings marshaller, arguments, callback, and module appear in RustFunctionGenerator, RustCallbackGenerator, and RustModuleGenerator.)
Prefix internal generated bindings with __valdi_ (e.g., __valdi_function, __valdi_marshaller, __valdi_arguments, __valdi_proxy).
Unprefixed internal bindings in RustCallbackGenerator collide with TypeScript parameter names
File: compiler/compiler/Compiler/Sources/Generation/Rust/RustCallbackGenerator.swift
When a TypeScript callback declares a parameter named callback, arguments, or marshaller, the generated Rust callback code fails to compile because internal local bindings shadow those parameters. The problem starts in RustCallbackGenerator.generateDefinition, where resultStatements binds arguments and createCall uses callback inside the same block as createArguments, and call_with binds marshaller around callValues.
In RustCallbackGenerator.generateDefinition:
- A parameter named
callbackproduceslet callback = ...;inside theresultblock, shadowing thecallback: Targument beforecallback.call(...)is invoked. - A parameter named
argumentsproduceslet arguments = ...;before subsequent parameters evaluatearguments.get(index)?, shadowing theMarshallerRefbinding. - A parameter named
marshallerinRef::callis shadowed by the|marshaller|closure argument incall_with, causingValdiPush::push_to(&marshaller, marshaller)to pass&mut Marshallerinstead of the parameter value.
Prefix the internal arguments, callback, and marshaller bindings in RustCallbackGenerator.generateDefinition (for example __valdi_arguments, __valdi_callback, __valdi_marshaller) so they cannot collide with TypeScript parameter names.
Unprefixed module and arguments bindings in RustModuleGenerator collide with TypeScript parameter names
File: compiler/compiler/Compiler/Sources/Generation/Rust/RustModuleGenerator.swift
When a TypeScript @ExportModule method declares a parameter named module or arguments, the generated Rust FFI invocation handler fails to compile because the deserialized parameter binding shadows the internal variable. The problem starts in RustModuleGenerator.write where invokeCases emits let arguments = unsafe { call.arguments() }; and module.<method>(...) inside the same scope as the deserialized parameter bindings.
A parameter named module generates let module = ...; inside the result block before module.<method>(...) runs, shadowing the &dyn <Name>Module reference bound outside the match; a parameter named arguments followed by another parameter shadows arguments before arguments.get(index)? executes for later parameters.
Rename the internal arguments and module bindings in RustModuleGenerator.write (for example __valdi_arguments and __valdi_module) so TypeScript parameter names cannot shadow them.
Closure binding marshaller in RustFunctionGenerator shadows a TypeScript parameter named marshaller
File: compiler/compiler/Compiler/Sources/Generation/Rust/RustFunctionGenerator.swift
When a TypeScript @ExportFunction declares a parameter named marshaller, the generated Rust call wrapper fails to compile because the closure parameter shadows the function parameter. The problem starts in RustFunctionGenerator.write, where callMarshaller binds "marshaller" for the call_with closure argument while serializedParameters passes parameter.name to ValdiPush::push_to.
Inside self.0.as_borrowed().call_with(|marshaller| { ... }), ValdiPush::push_to(&marshaller, marshaller)?; resolves the first marshaller to the &mut valdi_core_rust::Marshaller<'_> closure parameter rather than the function parameter, which fails trait resolution because Marshaller does not implement ValdiPush.
Change callMarshaller in RustFunctionGenerator.write to use a reserved internal name such as "__valdi_marshaller".
- 主要言語
- C++
- スター
- 16.4k
- フォーク
- 539
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Snapchat/Valdi のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
Rust codegen: RustMethodResolver fails to unwrap .nullable on optional interface/module methodsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
RTL-SDR: re-enumerating while streaming removes the in-use entry from the device selection dialog対応中かも @dpc00 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
throneproj/Throne#2227 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepseek-ai/DeepGEMM-Ascend#49 ·
メンテナーはふだん 1 日以内に返信