Skip to content

Commit

Permalink
enchance error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Nov 13, 2023
1 parent 761273c commit 6a0bdeb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions vlib/v/checker/comptime.v
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ fn (mut c Checker) comptime_for(mut node ast.ComptimeFor) {
c.comptime_for_field_var = ''
c.inside_comptime_for_field = false
} else if c.table.generic_type_names(node.typ).len == 0 && sym.kind != .placeholder {
c.error('comptime field lookup supports only structs and interfaces, and ${sym.name} is neither',
c.error('iterating over .fields is supported only for structs and interfaces, and ${sym.name} is neither',
node.typ_pos)
return
}
Expand All @@ -306,7 +306,7 @@ fn (mut c Checker) comptime_for(mut node ast.ComptimeFor) {
c.stmts(mut node.stmts)
}
} else {
c.error('comptime value lookup supports only enum, and ${sym.name} isn\'t',
c.error('iterating over .values is supported only for enums, and ${sym.name} is not an enum',
node.typ_pos)
return
}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/tests/for_comptime_enum_fields_err.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vlib/v/checker/tests/for_comptime_enum_fields_err.vv:6:11: error: comptime field lookup supports only structs and interfaces, and Test is neither
vlib/v/checker/tests/for_comptime_enum_fields_err.vv:6:11: error: iterating over .fields is supported only for structs and interfaces, and Test is neither
4 | }
5 |
6 | $for i in Test.fields {
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/tests/for_comptime_struct_values_err.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vlib/v/checker/tests/for_comptime_struct_values_err.vv:5:11: error: comptime value lookup supports only enum, and Foo isn't
vlib/v/checker/tests/for_comptime_struct_values_err.vv:5:11: error: iterating over .values is supported only for enums, and Foo is not an enum
3 | fn (_ Foo) hello() {}
4 |
5 | $for i in Foo.values {
Expand Down

0 comments on commit 6a0bdeb

Please sign in to comment.