ast: cleanup is_lit() (#14672)

master
yuyi 2022-06-04 02:02:36 +08:00 committed by GitHub
parent c15d1c6e7e
commit 66572d5ead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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