File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,7 +139,8 @@ fn (mut g Gen) comptime_call(mut node ast.ComptimeCall) {
139139 }
140140 return
141141 }
142- sym := g.table.sym (g.unwrap_generic (node.left_type))
142+ left_type := g.unwrap_generic (node.left_type)
143+ sym := g.table.sym (left_type)
143144 g.trace_autofree ('// \$ method call. sym="${sym .name }"' )
144145 if node.method_name == 'method' {
145146 // `app.$method()`
@@ -187,7 +188,7 @@ fn (mut g Gen) comptime_call(mut node ast.ComptimeCall) {
187188 }
188189 }
189190 // TODO: check argument types
190- g.write ('${util . no_dots ( sym . name )}_${g .comptime .comptime_for_method .name }(' )
191+ g.write ('${g . cc_type ( left_type , false )}_${g .comptime .comptime_for_method .name }(' )
191192
192193 // try to see if we need to pass a pointer
193194 if mut node.left is ast.Ident {
@@ -279,7 +280,7 @@ fn (mut g Gen) comptime_call(mut node ast.ComptimeCall) {
279280 }
280281 g.write ('if (string__eq(${node .method_name }, _SLIT("${method .name }"))) ' )
281282 }
282- g.write ('${util . no_dots ( sym . name )}_${method .name }(${amp } ' )
283+ g.write ('${g . cc_type ( left_type , false )}_${method .name }(${amp } ' )
283284 g.expr (node.left)
284285 g.writeln (');' )
285286 j++
Original file line number Diff line number Diff line change 1+ type Any = string | int
2+
3+ fn (m map[string]Any) to_toml () string {
4+ mut t := ''
5+ return t
6+ }
7+
8+ fn test_main () {
9+ mut doc := map [string ]Any{}
10+ _ := encode (doc)
11+ }
12+
13+ fn encode [T](typ T) string {
14+ $for method in T.methods {
15+ $if method.name == 'to_toml' {
16+ return typ.$method ()
17+ }
18+ }
19+ mp := encode_struct[T](typ)
20+ return mp.to_toml ()
21+ }
22+
23+ fn encode_struct [T](typ T) map [string ]Any {
24+ mut mp := map [string ]Any{}
25+ return mp
26+ }
You can’t perform that action at this time.
0 commit comments