remove undefined global constraint
This commit is contained in:
@@ -7891,7 +7891,7 @@ build_compound_expr :: proc(
|
||||
id := source.add(
|
||||
checker.diagnostics,
|
||||
expr.span,
|
||||
"'undefined' is only valid as a mutable local declaration initializer",
|
||||
"'undefined' is only valid as a mutable declaration initializer",
|
||||
)
|
||||
return invalid_hir_expr(checker, expr.span, id, expected)
|
||||
case .Enum_Literal:
|
||||
@@ -13686,7 +13686,20 @@ build_globals :: proc(checker: ^Checker) {
|
||||
is_runtime_type(checker, checker.global_types[global_index]) {
|
||||
expected = checker.global_types[global_index]
|
||||
}
|
||||
expr := build_expr(checker, global.expr, nil, &dependencies, &calls, expected, global.pkg, global.file)
|
||||
expr := hir.INVALID_EXPR
|
||||
if !global.immutable && is_undefined_expr(checker, global.expr) {
|
||||
expr = add_hir_expr(checker, hir.Expr{
|
||||
kind=.Undefined,
|
||||
span=checker.ast_module.exprs[global.expr].span,
|
||||
type=checker.global_types[global_index],
|
||||
target=hir.INVALID_REF,
|
||||
left=hir.INVALID_EXPR,
|
||||
right=hir.INVALID_EXPR,
|
||||
diagnostic=source.INVALID_DIAGNOSTIC,
|
||||
})
|
||||
} else {
|
||||
expr = build_expr(checker, global.expr, nil, &dependencies, &calls, expected, global.pkg, global.file)
|
||||
}
|
||||
global_type := checker.global_types[global_index]
|
||||
if is_runtime_type(checker, checker.global_types[global_index]) {
|
||||
expr = coerce_expr(checker, expr, checker.global_types[global_index], global.span)
|
||||
@@ -13713,17 +13726,6 @@ build_globals :: proc(checker: ^Checker) {
|
||||
global_type = constraint_recovery_type(checker, declared)
|
||||
expr = invalid_hir_expr(checker, global.span, diagnostic, global_type)
|
||||
}
|
||||
if !global.immutable && is_undefined_expr(checker, global.expr) {
|
||||
diagnostic = source.add(
|
||||
checker.diagnostics,
|
||||
global.span,
|
||||
"'undefined' is only valid as a mutable local declaration initializer",
|
||||
)
|
||||
if !is_runtime_type(checker, global_type) {
|
||||
global_type = types.I64
|
||||
}
|
||||
expr = invalid_hir_expr(checker, global.span, diagnostic, global_type)
|
||||
}
|
||||
if diagnostic == source.INVALID_DIAGNOSTIC && !is_runtime_type(checker, global_type) {
|
||||
if types.is_comptime_only(global_type, &checker.module.types) ||
|
||||
types.is_comptime_only(declared, &checker.module.types) {
|
||||
|
||||
Reference in New Issue
Block a user