0 issues 1 contributor 4 branches 0 releases
Additions: 32 Deletions: 2 View patch
1 funcprefix += 'isnil(it.${c_name(field.name)})'
2 funcprefix += ' ? _SLIT("nil") : '
3 // struct, floats and ints have a special case through the _str function
4- if sym.kind !in [.struct_, .alias] && !field.typ.is_int_valptr()
5+ if sym.kind !in [.struct_, .alias, .enum_] && !field.typ.is_int_valptr()
6 && !field.typ.is_float_valptr() {
7 funcprefix += '*'
8 }
9 sufix := if field_type.has_flag(.shared_f) { '->val' } else { '' }
10 deref, _ := deref_kind(expects_ptr, field_type.is_ptr(), field_type)
11 if sym.kind == .enum_ {
12- return '${fn_name}(${deref}it.${c_name(field_name)})', true
13+ return '${fn_name}(${deref}(it.${c_name(field_name)}))', true
14 } else if should_use_indent_func(sym.kind) {
15 obj := '${deref}it.${c_name(field_name)}$sufix'
16 if has_custom_str {
17
1 if expr !is ast.EnumVal {
2 str_fn_name := g.get_str_fn(typ)
3 g.write('${str_fn_name}(')
4+ if typ.is_ptr() {
5+ g.write('*')
6+ }
7 g.enum_expr(expr)
8 g.write(')')
9 } else {
10
1new file mode 100644
2+on
3+Foo{
4+ i: &on
5+}
6
1new file mode 100644
2+module main
3+
4+enum State {
5+ undef
6+ off
7+ on
8+}
9+
10+struct Foo {
11+ i &State
12+}
13+
14+fn main() {
15+ mut i := State.on
16+
17+ mut r := &i
18+ println(r)
19+
20+ mut f := Foo{
21+ i: &i
22+ }
23+ println(f)
24+}
25