Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.checker: remove notice when shifting signed int for @[translated] #20935

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}