File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -553,11 +553,17 @@ fn (mut g Gen) gen_array_map(node ast.CallExpr) {
553
553
ast.Ident {
554
554
g.write ('${ret_elem_type} ${tmp_map_expr_result_name} = ' )
555
555
if expr.kind == .function {
556
+ if expr.obj is ast.Var && expr.obj.is_inherited {
557
+ g.write (closure_ctx + '->' )
558
+ }
556
559
g.write ('${c_name(expr.name)} (${var_name} )' )
557
560
} else if expr.kind == .variable {
558
561
var_info := expr.var_info ()
559
562
sym := g.table.sym (var_info.typ)
560
563
if sym.kind == .function {
564
+ if expr.obj is ast.Var && expr.obj.is_inherited {
565
+ g.write (closure_ctx + '->' )
566
+ }
561
567
g.write ('${c_name(expr.name)} (${var_name} )' )
562
568
} else {
563
569
g.expr (expr)
Original file line number Diff line number Diff line change
1
+ struct Options {
2
+ }
3
+
4
+ fn sort_dictionary_order (mut lines []string , options Options) {
5
+ map_fn := fn (e u8 ) u8 {
6
+ return if e.is_digit () || e.is_letter () || e == ` ` { e } else { ` ` }
7
+ }
8
+ lines.sort_with_compare (fn [map_fn] (a & string , b & string ) int {
9
+ aa := a.bytes ().map (map_fn).bytestr ()
10
+ bb := b.bytes ().map (map_fn).bytestr ()
11
+ return compare_strings (aa, bb)
12
+ })
13
+ }
14
+
15
+ fn test_main () {
16
+ mut a := ['a' , 'b' , 'c' ].reverse ()
17
+ sort_dictionary_order (mut a, Options{})
18
+ assert dump (a) == ['a' , 'b' , 'c' ]
19
+ }
You can’t perform that action at this time.
0 commit comments