File tree 3 files changed +40
-1
lines changed
3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -4931,7 +4931,14 @@ fn (mut g Gen) ident(node ast.Ident) {
4931
4931
if node.obj.is_inherited {
4932
4932
g.write (closure_ctx + '->' )
4933
4933
}
4934
- g.write (name)
4934
+ if node.obj.typ.nr_muls () > 1 {
4935
+ g.write ('(' )
4936
+ g.write ('*' .repeat (node.obj.typ.nr_muls () - 1 ))
4937
+ g.write (name)
4938
+ g.write (')' )
4939
+ } else {
4940
+ g.write (name)
4941
+ }
4935
4942
if node.obj.orig_type.is_ptr () {
4936
4943
is_ptr = true
4937
4944
}
Original file line number Diff line number Diff line change @@ -695,6 +695,9 @@ fn (mut g Gen) infix_expr_is_op(node ast.InfixExpr) {
695
695
696
696
cmp_op := if node.op == .key_is { '==' } else { '!=' }
697
697
g.write ('(' )
698
+ if node.left_type.nr_muls () > 1 {
699
+ g.write ('*' .repeat (node.left_type.nr_muls () - 1 ))
700
+ }
698
701
if is_aggregate {
699
702
g.write ('${node.left} ' )
700
703
} else {
Original file line number Diff line number Diff line change
1
+ struct Parse {
2
+ mut :
3
+ stack []& Element
4
+ }
5
+
6
+ struct Balise {}
7
+
8
+ struct RawText {
9
+ s string
10
+ }
11
+
12
+ type Element = Balise | RawText
13
+
14
+ fn (mut p Parse) process_open_tag () string {
15
+ mut last := & p.stack[0 ]
16
+ if mut last is RawText {
17
+ println (last)
18
+ return last.s
19
+ } else {
20
+ return ''
21
+ }
22
+ }
23
+
24
+ fn test_sumtype_with_reference () {
25
+ mut parse := Parse{
26
+ stack: [& RawText{'raw' }]
27
+ }
28
+ assert parse.process_open_tag () == 'raw'
29
+ }
You can’t perform that action at this time.
0 commit comments