diff --git a/test_deprecated_with_date.v b/test_deprecated_with_date.v new file mode 100644 index 00000000000000..94cf8bb0bb20f5 --- /dev/null +++ b/test_deprecated_with_date.v @@ -0,0 +1,30 @@ +@[deprecated: '2025-10-10 !! use new function instead'] +fn d0() {} + +@[deprecated: '1234567890'] +fn d1() {} + +@[deprecated: ''] +fn d2() {} + +@[deprecated: 'a'] +fn d3() {} + +@[deprecated: 'lorem ipsum dolor sit'] +fn d4() {} + +@[deprecated: '2025-10-10!!close'] +fn d5() {} + +@[deprecated: ' 2025-10-10'] +fn d6() {} + +fn main() { + d0() + d1() + d2() + d3() + d4() + d5() + d6() +} diff --git a/vlib/v/checker/errors.v b/vlib/v/checker/errors.v index bf73cf52eb4d08..539b439a03e455 100644 --- a/vlib/v/checker/errors.v +++ b/vlib/v/checker/errors.v @@ -202,10 +202,15 @@ fn (mut c Checker) deprecate(kind string, name string, attrs []ast.Attr, pos tok } if attr.name == 'deprecated' { deprecation_message = attr.arg - } else if attr.name == 'deprecated_after' { - after_time = time.parse_iso8601(attr.arg) or { - c.error('invalid time format', attr.pos) - now + left_trimmed := attr.arg.trim_left(' ') + if left, right := left_trimmed.split_once('!!') { + if t := time.parse_iso8601(left.trim_right(' ')) { + after_time = t + deprecation_message = right.trim_left(' ') + } + } else if t := time.parse_iso8601(left_trimmed.trim_right(' ')) { + after_time = t + deprecation_message = '' } } } diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 06b73bc0d1e59c..e8c36f2ab822f9 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -227,7 +227,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl { 'manualfree' { is_manualfree = true } - 'deprecated' { + 'deprecated', 'deprecated_after' { is_deprecated = true } 'direct_array_access' {