Skip to content

Commit d696233

Browse files
authored
ast,parser: obsolete generic cleanup 2 (followup to #26126) (#26174)
1 parent fa4151b commit d696233

6 files changed

Lines changed: 7 additions & 16 deletions

File tree

vlib/v/ast/ast.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ pub mut:
903903
fn_var_type Type // the fn type, when `is_fn_a_const` or `is_fn_var` is true
904904
const_name string // the fully qualified name of the const, i.e. `main.c`, given `const c = abc`, and callexpr: `c()`
905905
should_be_skipped bool // true for calls to `[if someflag?]` functions, when there is no `-d someflag`
906-
concrete_types []Type // concrete types, e.g. <int, string>
906+
concrete_types []Type // concrete types, e.g. [int, string]
907907
concrete_list_pos token.Pos
908908
raw_concrete_types []Type
909909
free_receiver bool // true if the receiver expression needs to be freed

vlib/v/ast/table.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub mut:
8484
panic_npanics int
8585
cur_fn &FnDecl = unsafe { nil } // previously stored in Checker.cur_fn and Gen.cur_fn
8686
cur_lambda &LambdaExpr = unsafe { nil } // current lambda node
87-
cur_concrete_types []Type // current concrete types, e.g. <int, string>
87+
cur_concrete_types []Type // current concrete types, e.g. [int, string]
8888
gostmts int // how many `go` statements there were in the parsed files.
8989
// When table.gostmts > 0, __VTHREADS__ is defined, which can be checked with `$if threads {`
9090
enum_decls map[string]EnumDecl

vlib/v/parser/fn.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ fn (mut p Parser) call_expr(language ast.Language, mod string) ast.CallExpr {
4444

4545
mut concrete_types := []ast.Type{}
4646
mut concrete_list_pos := p.tok.pos()
47-
if p.tok.kind in [.lt, .lsbr] {
48-
// `foo<int>(10)`
47+
if p.tok.kind == .lsbr {
48+
// `foo[int](10)`
4949
p.expr_mod = ''
5050
concrete_types = p.parse_concrete_types()
5151
concrete_list_pos = concrete_list_pos.extend(p.prev_tok.pos())

vlib/v/parser/parse_type.v

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ fn (mut p Parser) parse_any_type(language ast.Language, is_ptr bool, check_dot b
800800
if name.len == 1 && name[0].is_capital() {
801801
return p.parse_generic_type(name)
802802
}
803-
if p.tok.kind in [.lt, .lsbr] && p.tok.is_next_to(p.prev_tok) {
803+
if p.tok.kind == .lsbr && p.tok.is_next_to(p.prev_tok) {
804804
return p.parse_generic_inst_type(name, name_pos)
805805
}
806806
return p.find_type_or_add_placeholder(name, language)
@@ -935,9 +935,6 @@ fn (mut p Parser) parse_generic_inst_type(name string, name_pos token.Pos) ast.T
935935
p.error('too many levels of Parser.parse_generic_inst_type() calls: ${p.generic_type_level}, probably due to too many layers embedded generic type')
936936
return ast.void_type
937937
}
938-
if p.tok.kind == .lt {
939-
p.error('The generic symbol `<>` is obsolete, please replace it with `[]`')
940-
}
941938
mut bs_name := name
942939
mut bs_cname := name
943940
start_pos := p.tok.pos()

vlib/v/parser/parser.v

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ fn (mut p Parser) name_expr() ast.Expr {
17311731
// type cast. TODO: finish
17321732
// if name in ast.builtin_type_names_to_idx {
17331733
// handle the easy cases first, then check for an already known V typename, not shadowed by a local variable
1734-
if (is_option || p.peek_tok.kind in [.lsbr, .lt, .lpar]) && (is_mod_cast
1734+
if (is_option || p.peek_tok.kind in [.lsbr, .lpar]) && (is_mod_cast
17351735
|| is_c_pointer_cast || is_c_type_cast || is_js_cast || is_generic_cast
17361736
|| (language == .v && name != '' && (is_capital_after_last_dot
17371737
|| name[0].is_capital()
@@ -2343,9 +2343,6 @@ fn (mut p Parser) dot_expr(left ast.Expr) ast.Expr {
23432343
fn (mut p Parser) parse_generic_types() ([]ast.Type, []string) {
23442344
mut types := []ast.Type{}
23452345
mut param_names := []string{}
2346-
if p.tok.kind == .lt {
2347-
p.error('The generic symbol `<>` is obsolete, please replace it with `[]`')
2348-
}
23492346
if p.tok.kind != .lsbr {
23502347
return types, param_names
23512348
}
@@ -2396,9 +2393,6 @@ fn (mut p Parser) parse_generic_types() ([]ast.Type, []string) {
23962393

23972394
fn (mut p Parser) parse_concrete_types() []ast.Type {
23982395
mut types := []ast.Type{}
2399-
if p.tok.kind == .lt {
2400-
p.error('The generic symbol `<>` is obsolete, please replace it with `[]`')
2401-
}
24022396
if p.tok.kind != .lsbr {
24032397
return types
24042398
}

vlib/v/parser/tests/generic_symbol_err.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vlib/v/parser/tests/generic_symbol_err.vv:1:13: error: The generic symbol `<>` is obsolete, please replace it with `[]`
1+
vlib/v/parser/tests/generic_symbol_err.vv:1:13: error: unexpected token `<`, expecting `(`
22
1 | pub fn what1<A>(params ...A) {
33
| ^
44
2 | println(params)

0 commit comments

Comments
 (0)