1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: fix notice of eval.infix.v on windows (#12770)

This commit is contained in:
yuyi 2021-12-10 21:28:32 +08:00 committed by GitHub
parent 9b4329d2f6
commit ed4ecae57d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ module checker
import v.ast
import v.token
import os
// TODO: promote(), check_types(), symmetric_check() and check() overlap - should be rearranged
pub fn (mut c Checker) check_types(got ast.Type, expected ast.Type) bool {
@ -244,6 +245,10 @@ pub fn (mut c Checker) check_matching_function_symbols(got_type_sym &ast.TypeSym
return true
}
// TODO: remove this exception, by using a more general mechanism for opting out
// generated code, from warnings/notices, that are targeted at humans:
const infix_v_exception = os.join_path('vlib', 'v', 'eval', 'infix.v')
fn (mut c Checker) check_shift(mut node ast.InfixExpr, left_type ast.Type, right_type ast.Type) ast.Type {
if !left_type.is_int() {
left_sym := c.table.get_type_symbol(left_type)
@ -303,7 +308,7 @@ fn (mut c Checker) check_shift(mut node ast.InfixExpr, left_type ast.Type, right
left_sym_final := c.table.get_final_type_symbol(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.file.path.contains('vlib/v/eval/infix.v')) {
&& c.file.path.ends_with(checker.infix_v_exception)) {
c.note('shifting a value from a signed type `$left_sym_final.name` can change the sign',
node.left.position())
}