mirror of
https://github.com/vlang/v.git
synced 2025-08-03 09:47:15 -04:00
fmt: fix eating the attribute from @[deprecated] pub type Alias = int
(fix #24968), workaround -usecache bug (#24969)
This commit is contained in:
parent
73db18bc0d
commit
6fb46cc30f
@ -131,12 +131,19 @@ fn build_fast_tcc() {
|
||||
|
||||
fn v_self_compilation_usecache_tcc() {
|
||||
exec('unset VFLAGS')
|
||||
|
||||
exec('v wipe-cache')
|
||||
exec('v -usecache examples/hello_world.v')
|
||||
exec('./examples/hello_world')
|
||||
|
||||
exec('v wipe-cache')
|
||||
exec('v -o v2 -usecache cmd/v')
|
||||
exec('./v2 -o v3 -usecache cmd/v')
|
||||
exec('./v3 version')
|
||||
|
||||
exec('v wipe-cache')
|
||||
exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
|
||||
exec('rm -f ./examples/hello_world v2 v3 tetris')
|
||||
}
|
||||
|
||||
fn test_password_input_tcc() {
|
||||
@ -198,13 +205,18 @@ fn v_self_compilation_gcc() {
|
||||
fn v_self_compilation_usecache_gcc() {
|
||||
exec('unset VFLAGS')
|
||||
|
||||
exec('v wipe-cache')
|
||||
exec('v -usecache examples/hello_world.v')
|
||||
exec('examples/hello_world')
|
||||
|
||||
exec('v wipe-cache')
|
||||
exec('v -o v2 -usecache cmd/v')
|
||||
exec('./v2 -o v3 -usecache cmd/v')
|
||||
exec('./v3 version')
|
||||
|
||||
exec('v wipe-cache')
|
||||
exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
|
||||
exec('rm -f ./examples/hello_world v2 v3 tetris')
|
||||
}
|
||||
|
||||
fn verify_v_test_works_gcc() {
|
||||
@ -312,11 +324,17 @@ fn v_self_compilation_clang() {
|
||||
|
||||
fn v_self_compilation_usecache_clang() {
|
||||
exec('unset VFLAGS')
|
||||
|
||||
exec('v wipe-cache')
|
||||
exec('v -usecache examples/hello_world.v')
|
||||
exec('./examples/hello_world')
|
||||
|
||||
exec('v wipe-cache')
|
||||
exec('v -o v2 -usecache cmd/v')
|
||||
exec('./v2 -o v3 -usecache cmd/v')
|
||||
exec('./v3 version')
|
||||
|
||||
exec('v wipe-cache')
|
||||
exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
|
||||
exec('rm -f ./examples/hello_world v2 v3 tetris')
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ module time
|
||||
// A lot of these are taken from the Go library.
|
||||
pub type Duration = i64
|
||||
|
||||
@[markused]
|
||||
pub const nanosecond = Duration(1)
|
||||
pub const microsecond = Duration(1000 * nanosecond)
|
||||
pub const millisecond = Duration(1000 * microsecond)
|
||||
|
@ -1483,6 +1483,7 @@ pub:
|
||||
pos token.Pos
|
||||
type_pos token.Pos
|
||||
comments []Comment
|
||||
attrs []Attr // attributes like @[deprecated] etc
|
||||
pub mut:
|
||||
parent_type Type
|
||||
is_markused bool
|
||||
|
@ -1686,6 +1686,7 @@ pub fn (mut f Fmt) type_decl(node ast.TypeDecl) {
|
||||
}
|
||||
|
||||
pub fn (mut f Fmt) alias_type_decl(node ast.AliasTypeDecl) {
|
||||
f.attrs(node.attrs)
|
||||
if node.is_pub {
|
||||
f.write('pub ')
|
||||
}
|
||||
|
@ -30,3 +30,7 @@ enum Example {
|
||||
value1 = 1
|
||||
value1_again = 1
|
||||
}
|
||||
|
||||
@[deprecated: 'use Example instead']
|
||||
@[deprecated_after: '2040-01-24']
|
||||
pub type Alias = Example
|
||||
|
@ -2749,6 +2749,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
|
||||
return ast.AliasTypeDecl{}
|
||||
}
|
||||
comments = sum_variants[0].end_comments.clone()
|
||||
p.attrs = []
|
||||
return ast.AliasTypeDecl{
|
||||
name: name
|
||||
is_pub: is_pub
|
||||
@ -2758,6 +2759,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
|
||||
pos: decl_pos
|
||||
comments: comments
|
||||
is_markused: attrs.contains('markused')
|
||||
attrs: attrs
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user