Mutating functions are not supported on structs
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript, swift, wasm
Research direction
Start with the @JS struct handling and the generated _bjs_Counter_increment wrapper shown in the issue, then reproduce the compilation failure with the Counter example. Done means an @JS struct with a mutating function generates code that compiles successfully for WebAssembly.
Written by the indexing model from the issue text.
Description
Marking a mutating function on a structure @JS results in a compilation failure in the generated code.
For example, this struct generates code which fails to compile.
@JS struct Counter {
var number: Int
@JS public mutating func increment() {
number += 1
}
}
@_expose(wasm, "bjs_Counter_increment")
@_cdecl("bjs_Counter_increment")
public func _bjs_Counter_increment() -> Void {
#if arch(wasm32)
Counter.bridgeJSLiftParameter().increment() // error: cannot use mutating member on immutable value: function call returns immutable value
#else
fatalError("Only available on WebAssembly")
#endif
}
- Dominant language
- Swift
- Stars
- 986
- Forks
- 76
- Avg merge
- 21h 11m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from swiftwasm/JavaScriptKit
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
swiftwasm/JavaScriptKit#793 ·
-
swiftwasm/JavaScriptKit#785 · 1 assignee ·
-
[SwiftBuild] Preserve duplicate archive members when SwiftBuild expands static archives for linking Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
swiftwasm/JavaScriptKit#781 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
swiftwasm/JavaScriptKit#773 ·
-
swiftwasm/JavaScriptKit#767 · 1 assignee ·
All issues in swiftwasm/JavaScriptKit
Similar issues
-
area:dictation documentation P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
uttrflow/uttrflow-swift#1180 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
OneBusAway/onebusaway-ios#1451 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100