From 22683f4d32dd3a00cae5d2eb7b2bf74e29a78d7d Mon Sep 17 00:00:00 2001 From: MCausc78 Date: Fri, 1 Mar 2024 18:35:50 +0200 Subject: [PATCH 1/3] impl --- vlib/v/checker/check_types.v | 2 +- vlib/v/checker/tests/no_sign_notice_in_translated.out | 1 + vlib/v/checker/tests/no_sign_notice_in_translated.vv | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 vlib/v/checker/tests/no_sign_notice_in_translated.out create mode 100644 vlib/v/checker/tests/no_sign_notice_in_translated.vv diff --git a/vlib/v/checker/check_types.v b/vlib/v/checker/check_types.v index c7d6f21fb1350f..30f648ac07d5a7 100644 --- a/vlib/v/checker/check_types.v +++ b/vlib/v/checker/check_types.v @@ -534,7 +534,7 @@ fn (mut c Checker) check_shift(mut node ast.InfixExpr, left_type_ ast.Type, righ left_sym_final := c.table.final_sym(left_type) left_type_final := ast.Type(left_sym_final.idx) if node.op == .left_shift && left_type_final.is_signed() && !(c.inside_unsafe - && c.is_generated) { + && c.is_generated) && !c.pref.translated && !c.file.is_translated { c.note('shifting a value from a signed type `${left_sym_final.name}` can change the sign', node.left.pos()) } diff --git a/vlib/v/checker/tests/no_sign_notice_in_translated.out b/vlib/v/checker/tests/no_sign_notice_in_translated.out new file mode 100644 index 00000000000000..3cacc0b93c9c9c --- /dev/null +++ b/vlib/v/checker/tests/no_sign_notice_in_translated.out @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/vlib/v/checker/tests/no_sign_notice_in_translated.vv b/vlib/v/checker/tests/no_sign_notice_in_translated.vv new file mode 100644 index 00000000000000..bf1ec09ddb8116 --- /dev/null +++ b/vlib/v/checker/tests/no_sign_notice_in_translated.vv @@ -0,0 +1,10 @@ +@[translated] +module main + +fn f(i i32) i32 { + return i << 2 +} + +fn main() { + println(f(3)) +} From aa4038e998c01bebbe59b4f527ed0db74a69b6b4 Mon Sep 17 00:00:00 2001 From: MCausc78 Date: Fri, 1 Mar 2024 18:37:35 +0200 Subject: [PATCH 2/3] forgor --- vlib/v/checker/tests/no_sign_notice_in_translated.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlib/v/checker/tests/no_sign_notice_in_translated.out b/vlib/v/checker/tests/no_sign_notice_in_translated.out index 3cacc0b93c9c9c..48082f72f087ce 100644 --- a/vlib/v/checker/tests/no_sign_notice_in_translated.out +++ b/vlib/v/checker/tests/no_sign_notice_in_translated.out @@ -1 +1 @@ -12 \ No newline at end of file +12 From 36e84a25bbc3e86d87be81ad4aa715ecde95be54 Mon Sep 17 00:00:00 2001 From: MCausc78 Date: Fri, 1 Mar 2024 19:08:46 +0200 Subject: [PATCH 3/3] fix --- vlib/v/checker/tests/no_sign_notice_in_translated.out | 1 - vlib/v/checker/tests/no_sign_notice_in_translated.vv | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/vlib/v/checker/tests/no_sign_notice_in_translated.out b/vlib/v/checker/tests/no_sign_notice_in_translated.out index 48082f72f087ce..e69de29bb2d1d6 100644 --- a/vlib/v/checker/tests/no_sign_notice_in_translated.out +++ b/vlib/v/checker/tests/no_sign_notice_in_translated.out @@ -1 +0,0 @@ -12 diff --git a/vlib/v/checker/tests/no_sign_notice_in_translated.vv b/vlib/v/checker/tests/no_sign_notice_in_translated.vv index bf1ec09ddb8116..a1f8247d39e43f 100644 --- a/vlib/v/checker/tests/no_sign_notice_in_translated.vv +++ b/vlib/v/checker/tests/no_sign_notice_in_translated.vv @@ -6,5 +6,5 @@ fn f(i i32) i32 { } fn main() { - println(f(3)) + assert f(3) == 12 }