diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index a45191efb0..658d3cc599 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -1825,9 +1825,9 @@ pub fn (expr Expr) is_expr() bool { return true } -pub fn (expr Expr) is_lit() bool { +pub fn (expr Expr) is_pure_literal() bool { return match expr { - BoolLiteral, CharLiteral, StringLiteral, IntegerLiteral { true } + BoolLiteral, CharLiteral, FloatLiteral, StringLiteral, IntegerLiteral { true } else { false } } } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 1d9a637920..9721273807 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -742,7 +742,7 @@ fn (mut c Checker) fail_if_immutable(expr_ ast.Expr) (string, token.Pos) { return '', pos } else { - if !expr.is_lit() { + if !expr.is_pure_literal() { c.error('unexpected expression `$expr.type_name()`', expr.pos()) return '', pos } @@ -3058,7 +3058,7 @@ fn (mut c Checker) find_obj_definition(obj ast.ScopeObject) ?ast.Expr { if mut expr is ast.Ident { return c.find_definition(expr) } - if !expr.is_lit() { + if !expr.is_pure_literal() { return error('definition of `$name` is unknown at compile time') } return expr