From 66572d5ead57aaee433e52feac35fb7cf336b7e3 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sat, 4 Jun 2022 02:02:36 +0800 Subject: [PATCH] ast: cleanup is_lit() (#14672) --- vlib/v/ast/ast.v | 4 ++-- vlib/v/checker/checker.v | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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