Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed May 31, 2024
1 parent 5ac8249 commit e78a46a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vlib/v/checker/tests/missing_concrete_type_err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vlib/v/checker/tests/missing_concrete_type_err.vv:4:6: error: missing concrete type on generic type
2 |
3 | fn main() {
4 | bar[Foo]()
| ~~~
5 | }
6 |
9 changes: 9 additions & 0 deletions vlib/v/checker/tests/missing_concrete_type_err.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
struct Foo[T] {}

fn main() {
bar[Foo]()
}

fn bar[T]() {

}
5 changes: 5 additions & 0 deletions vlib/v/parser/parse_type.v
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,11 @@ fn (mut p Parser) parse_type() ast.Type {
return 0
}
sym := p.table.sym(typ)
if sym.info is ast.Struct {
if !typ.has_flag(.generic) && sym.info.generic_types.len > 0 {
p.error_with_pos('missing concrete type on generic type', option_pos.extend(p.prev_tok.pos()))
}
}
if is_option && sym.info is ast.SumType && sym.info.is_anon {
p.error_with_pos('an inline sum type cannot be an Option', option_pos.extend(p.prev_tok.pos()))
}
Expand Down

0 comments on commit e78a46a

Please sign in to comment.