pull/13636/head
parent
57c6454656
commit
6a3d34ae11
|
@ -1667,6 +1667,12 @@ pub fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type {
|
|||
if sym.kind !in [.struct_, .aggregate, .interface_, .sum_type] {
|
||||
if sym.kind != .placeholder {
|
||||
unwrapped_sym := c.table.sym(c.unwrap_generic(typ))
|
||||
|
||||
if unwrapped_sym.kind == .array_fixed && node.field_name == 'len' {
|
||||
node.typ = ast.int_type
|
||||
return ast.int_type
|
||||
}
|
||||
|
||||
c.error('`$unwrapped_sym.name` has no property `$node.field_name`', node.pos)
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
fn test_comptime_generic() {
|
||||
a := [5]int{}
|
||||
func1(&a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn func1<T>(t &T) {
|
||||
func2<T>(t)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn func2<T>(t &T) {
|
||||
$if T is $Array {
|
||||
unsafe {
|
||||
for i in 0 .. t.len {
|
||||
func2(&t[i])
|
||||
}
|
||||
}
|
||||
} $else $if T is $Map {
|
||||
// fake_map(t, df)
|
||||
} $else $if T is $Struct {
|
||||
$for f in T.fields {
|
||||
$if f.typ is string {
|
||||
}
|
||||
// Dummy expression to generate and specify t.$(f.name)'s type
|
||||
|
||||
// mut attrs := get_attrs(t.$(f.name), f)
|
||||
|
||||
// if !attrs.skip() {
|
||||
// fake_data_wdf(&(t.$(f.name)))
|
||||
// }
|
||||
}
|
||||
} $else {
|
||||
unsafe {
|
||||
// *t = fake_primitive_value<T>(df) or { panic(err) }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue