Skip to content

Commit

Permalink
Type: use canonicalize for isArray
Browse files Browse the repository at this point in the history
  • Loading branch information
ehaas committed Aug 23, 2024
1 parent 64804c0 commit b42d19d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/aro/Type.zig
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,12 @@ pub fn isFunc(ty: Type) bool {
}

pub fn isArray(ty: Type) bool {
return switch (ty.specifier) {
.array, .static_array, .incomplete_array, .variable_len_array, .unspecified_variable_len_array => !ty.isDecayed(),
.typeof_type => !ty.isDecayed() and ty.data.sub_type.isArray(),
.typeof_expr => !ty.isDecayed() and ty.data.expr.ty.isArray(),
.attributed => !ty.isDecayed() and ty.data.attributed.base.isArray(),
const canon = ty.canonicalize(.standard);
return switch (canon.specifier) {
.array, .static_array, .incomplete_array, .variable_len_array, .unspecified_variable_len_array => !canon.isDecayed(),
.typeof_type => unreachable,
.typeof_expr => unreachable,
.attributed => unreachable,
else => false,
};
}
Expand Down

0 comments on commit b42d19d

Please sign in to comment.