ast: cleanup is_lit() (#14672)

yuyi 2022-06-04 02:02:36 +08:00 committed by Chewing_Bever
parent 54e851f8de
commit bff84aab59
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 4 additions and 4 deletions

View File

@ -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 }
}
}

View File

@ -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