File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -391,7 +391,7 @@ fn (mut g JsGen) gen_call_expr(it ast.CallExpr) {
391391 if it .should_be_skipped {
392392 return
393393 }
394- if it .is_method && g.table.sym (it .receiver_type).name.starts_with ('JS.' ) {
394+ if it .is_method && ( it .is_field || g.table.sym (it .receiver_type).name.starts_with ('JS.' ) ) {
395395 g.js_method_call (it )
396396 return
397397 } else if it .name.starts_with ('JS.' ) {
Original file line number Diff line number Diff line change 1+ struct FooParams {
2+ name string
3+ update fn (name string ) @[required]
4+ }
5+
6+ fn foo (params FooParams) {
7+ params.update (params.name)
8+ }
9+
10+ fn main () {
11+ // anonymous function callback
12+ foo (
13+ name: 'item 1'
14+ update: fn (name string ) {
15+ println ('update ${name }' )
16+ }
17+ )
18+
19+ // lambda function callback
20+ update := fn (name string ) {
21+ println ('update ${name }' )
22+ }
23+ foo (name: 'item 2' , update: update)
24+
25+ // anonymous function field
26+ item_3 := FooParams{
27+ update: fn (name string ) {
28+ println ('update ${name }' )
29+ }
30+ }
31+ item_3 .update ('item 3' )
32+
33+ // lambda function field
34+ item_4 := FooParams{
35+ update: update
36+ }
37+ item_4 .update ('item 4' )
38+ }
You can’t perform that action at this time.
0 commit comments