diff --git a/ci/linux_ci.vsh b/ci/linux_ci.vsh index 1c5c90e9e2..a97e3a56ba 100644 --- a/ci/linux_ci.vsh +++ b/ci/linux_ci.vsh @@ -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') } diff --git a/vlib/time/duration.v b/vlib/time/duration.v index 2d61394a0b..aa2e08034b 100644 --- a/vlib/time/duration.v +++ b/vlib/time/duration.v @@ -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) diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 2438743ce9..fdbe84f6b7 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -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 diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index c95643f223..cded853c41 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -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 ') } diff --git a/vlib/v/fmt/tests/attrs_keep.vv b/vlib/v/fmt/tests/attrs_keep.vv index d8976652ca..d027a8538a 100644 --- a/vlib/v/fmt/tests/attrs_keep.vv +++ b/vlib/v/fmt/tests/attrs_keep.vv @@ -30,3 +30,7 @@ enum Example { value1 = 1 value1_again = 1 } + +@[deprecated: 'use Example instead'] +@[deprecated_after: '2040-01-24'] +pub type Alias = Example diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index c098a8900f..7af252379c 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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 } }