From 15f4594e44e14fca831aee221fbd460d66539080 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 11 Apr 2020 13:35:41 +0300 Subject: [PATCH] msvc: fix self compile, by avoiding explicit casting to the same type --- vlib/v/checker/checker.v | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index aa76eca1db..97d1a9a9e1 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -752,10 +752,9 @@ pub fn (c mut Checker) array_init(array_init mut ast.ArrayInit) table.Type { mut full_const_name := if it.mod == 'main' { it.name } else { it.mod + '.' + it.name } if obj := c.file.global_scope.find_const(full_const_name) { - cf := ast.ConstField(obj) - if cint := is_const_integer(cf) { - fixed_size = cint.val.int() - } + if cint := const_int_value( obj ) { + fixed_size = cint + } } else { c.error('non existant integer const $full_const_name while initializing the size of a static array', array_init.pos) @@ -772,6 +771,13 @@ pub fn (c mut Checker) array_init(array_init mut ast.ArrayInit) table.Type { return array_init.typ } +fn const_int_value(cfield ast.ConstField) ?int { + if cint := is_const_integer(cfield) { + return cint.val.int() + } + return none +} + fn is_const_integer(cfield ast.ConstField) ?ast.IntegerLiteral { match cfield.expr { ast.IntegerLiteral {