ast: cleanup is_lit() (#14672)
parent
c15d1c6e7e
commit
66572d5ead
|
@ -1825,9 +1825,9 @@ pub fn (expr Expr) is_expr() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (expr Expr) is_lit() bool {
|
pub fn (expr Expr) is_pure_literal() bool {
|
||||||
return match expr {
|
return match expr {
|
||||||
BoolLiteral, CharLiteral, StringLiteral, IntegerLiteral { true }
|
BoolLiteral, CharLiteral, FloatLiteral, StringLiteral, IntegerLiteral { true }
|
||||||
else { false }
|
else { false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -742,7 +742,7 @@ fn (mut c Checker) fail_if_immutable(expr_ ast.Expr) (string, token.Pos) {
|
||||||
return '', pos
|
return '', pos
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if !expr.is_lit() {
|
if !expr.is_pure_literal() {
|
||||||
c.error('unexpected expression `$expr.type_name()`', expr.pos())
|
c.error('unexpected expression `$expr.type_name()`', expr.pos())
|
||||||
return '', 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 {
|
if mut expr is ast.Ident {
|
||||||
return c.find_definition(expr)
|
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 error('definition of `$name` is unknown at compile time')
|
||||||
}
|
}
|
||||||
return expr
|
return expr
|
||||||
|
|
Loading…
Reference in New Issue