Skip to content

[wasm] JSExport function with void return and parameters generate rest args #126590

@MartelementAyy

Description

@MartelementAyy

Describe the bug

When using the attribute [JSExport] on a method with void return type and at least one parameter, the generated JS uses rest args instead of explicit params.

To Reproduce

Github project for reproduction : https://github.com/MartelementAyy/JSExportVoidBug

Basically
[JSExport] public static void BrokenVoid(int a, int b) { Console.WriteLine($"{a} {b}"); }

[JSExport] public static int WorkingInt(int a, int b) { return a + b; }

Result :

BrokenVoid: ƒ (...e){const c=Ft();lt.assert_runtime_running();const l=Ke.stackSave();try{const s=$n(2+t);for(let r=0;r<t;r++){const t=n[r];t&&t(s,e[r])}let c;return a&&(c=r(s)),a?(wn(ct.managedThreadTID,o,s),c=an(…

WorkingInt: ƒ (e,a){const i=Ft();lt.assert_runtime_running();const c=Ke.stackSave();try{const s=$n(4);return n(s,e),r(s,a),kn(t,s),o(s)}finally{lt.is_runtime_running()&&Ke.stackRestore(c),Pt(i,"mono.callCsFunction…

Further technical details

details of dotnet --info

.NET SDK: Version: 10.0.200 Commit: 40cd698e5c Workload version: 10.0.201 MSBuild version: 18.3.0-release-26119-122+40cd698e5

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.200\

.NET workloads installed:
[wasm-tools]
Installation Source: SDK 10.0.200
Manifest Version: 10.0.105/10.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\10.0.100\microsoft.net.workload.mono.toolchain.current\10.0.105\WorkloadManifest.json
Install Type: Msi

Configured to use workload sets when installing new manifests.

Host:
Version: 10.0.4
Architecture: x64
Commit: 80d3e14f5e

.NET SDKs installed:
6.0.414 [C:\Program Files\dotnet\sdk]
10.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions