Skip to content

Commit

Permalink
checker: remove notice when shifting signed int for @[translated] (v…
Browse files Browse the repository at this point in the history
  • Loading branch information
MCausc78 authored and robin-randhawa-sifive committed Mar 9, 2024
1 parent bbdd6c5 commit 78f4091
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/checker/check_types.v
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
Empty file.
10 changes: 10 additions & 0 deletions vlib/v/checker/tests/no_sign_notice_in_translated.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@[translated]
module main

fn f(i i32) i32 {
return i << 2
}

fn main() {
assert f(3) == 12
}

0 comments on commit 78f4091

Please sign in to comment.