Skip to content

Commit

Permalink
parser: make old [attr] syntax an error
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Jan 19, 2025
1 parent 11c59cf commit f9d3bd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/tools/test_if_v_test_system_works.v
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn check_assert_continues_works() ! {
result.has('assert_continues_option_works_test.v:5: fn test_fail2')
result.has('> assert 2 == 4').has('> assert 2 == 1').has('> assert 2 == 0')
// Check if a test function, tagged with [assert_continues], has the same behaviour, without needing additional options
create_test('assert_continues_tag_works_test.v', '[assert_continues]fn test_fail1() { assert 2==4\nassert 2==1\nassert 2==0 }\nfn test_ok(){ assert true }\nfn test_fail2() { assert false\n assert false }')!
create_test('assert_continues_tag_works_test.v', '@[assert_continues]fn test_fail1() { assert 2==4\nassert 2==1\nassert 2==0 }\nfn test_ok(){ assert true }\nfn test_fail2() { assert false\n assert false }')!
tag_res := check_fail('${vexe} assert_continues_tag_works_test.v')
tag_res.has('assert_continues_tag_works_test.v:1: fn test_fail1')
tag_res.has('assert_continues_tag_works_test.v:2: fn test_fail1')
Expand Down
7 changes: 5 additions & 2 deletions vlib/v/parser/parser.v
Original file line number Diff line number Diff line change
Expand Up @@ -1937,12 +1937,15 @@ fn (mut p Parser) is_attributes() bool {
return true
}

// when is_top_stmt is true attrs are added to p.attrs
// when is_top_stmt is true, attrs are added to p.attrs
fn (mut p Parser) attributes() {
start_pos := p.tok.pos()
mut is_at := false
if p.tok.kind == .lsbr {
p.warn('`[attr]` has been deprecated, use `@[attr]` instead')
if p.pref.is_fmt {
} else {
p.error('`[attr]` has been deprecated, use `@[attr]` instead')
}
// [attr]
p.check(.lsbr)
} else if p.tok.kind == .at {
Expand Down

0 comments on commit f9d3bd3

Please sign in to comment.