intern identifiers
This commit is contained in:
@@ -3,6 +3,7 @@ package checker
|
||||
import "../ast"
|
||||
import "../hir"
|
||||
import "../source"
|
||||
import "../symbol"
|
||||
import "../types"
|
||||
import "base:intrinsics"
|
||||
import "core:fmt"
|
||||
@@ -18,12 +19,12 @@ Spec :: struct {
|
||||
}
|
||||
|
||||
Infer_Local :: struct {
|
||||
name: string,
|
||||
name: symbol.Id,
|
||||
type: types.Type,
|
||||
}
|
||||
|
||||
Build_Local :: struct {
|
||||
name: string,
|
||||
name: symbol.Id,
|
||||
type: types.Type,
|
||||
mutable: bool,
|
||||
id: int,
|
||||
@@ -43,13 +44,14 @@ Constant :: struct {
|
||||
|
||||
Symbol_Index_Entry :: struct {
|
||||
scope: int,
|
||||
name: string,
|
||||
name: symbol.Id,
|
||||
id: int,
|
||||
}
|
||||
|
||||
Checker :: struct {
|
||||
ast_module: ^ast.Module,
|
||||
diagnostics: ^source.Diagnostics,
|
||||
symbols: ^symbol.Table,
|
||||
module: hir.Module,
|
||||
specs: [dynamic]Spec,
|
||||
function_index: []Symbol_Index_Entry,
|
||||
@@ -57,9 +59,15 @@ Checker :: struct {
|
||||
import_index: []Symbol_Index_Entry,
|
||||
global_types: []types.Type,
|
||||
constants: []Constant,
|
||||
main_symbol: symbol.Id,
|
||||
sink_symbol: symbol.Id,
|
||||
allocator: mem.Allocator,
|
||||
}
|
||||
|
||||
symbol_text :: proc(checker: ^Checker, id: symbol.Id) -> string {
|
||||
return symbol.resolve(checker.symbols, id)
|
||||
}
|
||||
|
||||
eval_constant :: proc(checker: ^Checker, expr_id: int) -> Constant {
|
||||
if expr_id < 0 || expr_id >= len(checker.ast_module.exprs) {
|
||||
return Constant{kind = .Not_Constant}
|
||||
@@ -131,18 +139,18 @@ symbol_index_less :: proc(left, right: Symbol_Index_Entry) -> bool {
|
||||
return left.scope < right.scope
|
||||
}
|
||||
if left.name != right.name {
|
||||
return left.name < right.name
|
||||
return int(left.name) < int(right.name)
|
||||
}
|
||||
return left.id < right.id
|
||||
}
|
||||
|
||||
find_symbol :: proc(index: []Symbol_Index_Entry, scope: int, name: string) -> int {
|
||||
find_symbol :: proc(index: []Symbol_Index_Entry, scope: int, name: symbol.Id) -> int {
|
||||
low := 0
|
||||
high := len(index)
|
||||
for low < high {
|
||||
middle := low + (high-low)/2
|
||||
entry := index[middle]
|
||||
if entry.scope < scope || entry.scope == scope && entry.name < name {
|
||||
if entry.scope < scope || entry.scope == scope && int(entry.name) < int(name) {
|
||||
low = middle + 1
|
||||
} else {
|
||||
high = middle
|
||||
@@ -174,15 +182,15 @@ build_symbol_indexes :: proc(checker: ^Checker) {
|
||||
slice.sort_by(checker.import_index, symbol_index_less)
|
||||
}
|
||||
|
||||
find_template :: proc(checker: ^Checker, name: string, pkg := 0) -> int {
|
||||
find_template :: proc(checker: ^Checker, name: symbol.Id, pkg := 0) -> int {
|
||||
return find_symbol(checker.function_index, pkg, name)
|
||||
}
|
||||
|
||||
find_global :: proc(checker: ^Checker, name: string, pkg := 0) -> int {
|
||||
find_global :: proc(checker: ^Checker, name: symbol.Id, pkg := 0) -> int {
|
||||
return find_symbol(checker.global_index, pkg, name)
|
||||
}
|
||||
|
||||
find_import :: proc(checker: ^Checker, file: int, alias: string, mark_used := false) -> int {
|
||||
find_import :: proc(checker: ^Checker, file: int, alias: symbol.Id, mark_used := false) -> int {
|
||||
id := find_symbol(checker.import_index, file, alias)
|
||||
if id >= 0 && mark_used {
|
||||
checker.ast_module.imports[id].used = true
|
||||
@@ -191,7 +199,7 @@ find_import :: proc(checker: ^Checker, file: int, alias: string, mark_used := fa
|
||||
}
|
||||
|
||||
expr_package :: proc(checker: ^Checker, expr: ast.Expr, pkg, file: int, mark_used := false) -> (int, bool) {
|
||||
if expr.qualifier == "" {
|
||||
if !symbol.is_valid(expr.qualifier) {
|
||||
return pkg, true
|
||||
}
|
||||
import_id := find_import(checker, file, expr.qualifier, mark_used)
|
||||
@@ -208,44 +216,44 @@ expr_package :: proc(checker: ^Checker, expr: ast.Expr, pkg, file: int, mark_use
|
||||
|
||||
add_package_resolution_diagnostic :: proc(checker: ^Checker, expr: ast.Expr, file: int) -> int {
|
||||
if find_import(checker, file, expr.qualifier) < 0 {
|
||||
return source.addf(checker.diagnostics, expr.span, "unknown package alias '%s'", expr.qualifier)
|
||||
return source.addf(checker.diagnostics, expr.span, "unknown package alias '%s'", symbol_text(checker, expr.qualifier))
|
||||
}
|
||||
return source.addf(checker.diagnostics, expr.span, "unavailable imported package '%s'", expr.qualifier)
|
||||
return source.addf(checker.diagnostics, expr.span, "unavailable imported package '%s'", symbol_text(checker, expr.qualifier))
|
||||
}
|
||||
|
||||
add_name_resolution_diagnostic :: proc(checker: ^Checker, expr: ast.Expr, target_pkg: int) -> int {
|
||||
if find_template(checker, expr.text, target_pkg) >= 0 {
|
||||
return source.addf(checker.diagnostics, expr.span, "'%s' is a function, not a global value", expr.text)
|
||||
if find_template(checker, expr.name, target_pkg) >= 0 {
|
||||
return source.addf(checker.diagnostics, expr.span, "'%s' is a function, not a global value", symbol_text(checker, expr.name))
|
||||
}
|
||||
if expr.qualifier != "" {
|
||||
if symbol.is_valid(expr.qualifier) {
|
||||
return source.addf(
|
||||
checker.diagnostics,
|
||||
expr.span,
|
||||
"package '%s' has no member '%s'",
|
||||
expr.qualifier,
|
||||
expr.text,
|
||||
symbol_text(checker, expr.qualifier),
|
||||
symbol_text(checker, expr.name),
|
||||
)
|
||||
}
|
||||
return source.addf(checker.diagnostics, expr.span, "unresolved global '%s'", expr.text)
|
||||
return source.addf(checker.diagnostics, expr.span, "unresolved global '%s'", symbol_text(checker, expr.name))
|
||||
}
|
||||
|
||||
add_call_resolution_diagnostic :: proc(checker: ^Checker, expr: ast.Expr, target_pkg: int) -> int {
|
||||
if find_global(checker, expr.text, target_pkg) >= 0 {
|
||||
return source.addf(checker.diagnostics, expr.span, "'%s' is a global, not a function", expr.text)
|
||||
if find_global(checker, expr.name, target_pkg) >= 0 {
|
||||
return source.addf(checker.diagnostics, expr.span, "'%s' is a global, not a function", symbol_text(checker, expr.name))
|
||||
}
|
||||
if expr.qualifier != "" {
|
||||
if symbol.is_valid(expr.qualifier) {
|
||||
return source.addf(
|
||||
checker.diagnostics,
|
||||
expr.span,
|
||||
"package '%s' has no member '%s'",
|
||||
expr.qualifier,
|
||||
expr.text,
|
||||
symbol_text(checker, expr.qualifier),
|
||||
symbol_text(checker, expr.name),
|
||||
)
|
||||
}
|
||||
return source.addf(checker.diagnostics, expr.span, "unresolved function '%s'", expr.text)
|
||||
return source.addf(checker.diagnostics, expr.span, "unresolved function '%s'", symbol_text(checker, expr.name))
|
||||
}
|
||||
|
||||
contains_name :: proc(names: []string, name: string) -> bool {
|
||||
contains_name :: proc(names: []symbol.Id, name: symbol.Id) -> bool {
|
||||
for existing in names {
|
||||
if existing == name {
|
||||
return true
|
||||
@@ -261,11 +269,11 @@ mark_expr_imports_used :: proc(checker: ^Checker, expr_id, file: int) {
|
||||
expr := checker.ast_module.exprs[expr_id]
|
||||
switch expr.kind {
|
||||
case .Name:
|
||||
if expr.qualifier != "" {
|
||||
if symbol.is_valid(expr.qualifier) {
|
||||
_ = find_import(checker, file, expr.qualifier, true)
|
||||
}
|
||||
case .Call:
|
||||
if expr.qualifier != "" {
|
||||
if symbol.is_valid(expr.qualifier) {
|
||||
_ = find_import(checker, file, expr.qualifier, true)
|
||||
}
|
||||
for arg in expr.args {
|
||||
@@ -280,7 +288,7 @@ mark_expr_imports_used :: proc(checker: ^Checker, expr_id, file: int) {
|
||||
|
||||
validate_declarations :: proc(checker: ^Checker) {
|
||||
for function in checker.ast_module.functions {
|
||||
locals: [dynamic]string
|
||||
locals: [dynamic]symbol.Id
|
||||
locals.allocator = checker.allocator
|
||||
for param in function.params {
|
||||
if param.type == .Void {
|
||||
@@ -295,7 +303,7 @@ validate_declarations :: proc(checker: ^Checker) {
|
||||
checker.diagnostics,
|
||||
param.span,
|
||||
"duplicate parameter '%s'",
|
||||
param.name,
|
||||
symbol_text(checker, param.name),
|
||||
)
|
||||
}
|
||||
append(&locals, param.name)
|
||||
@@ -312,7 +320,7 @@ validate_declarations :: proc(checker: ^Checker) {
|
||||
}
|
||||
}
|
||||
|
||||
find_infer_local :: proc(locals: []Infer_Local, name: string) -> types.Type {
|
||||
find_infer_local :: proc(locals: []Infer_Local, name: symbol.Id) -> types.Type {
|
||||
for index := len(locals) - 1; index >= 0; index -= 1 {
|
||||
if locals[index].name == name {
|
||||
return locals[index].type
|
||||
@@ -372,7 +380,7 @@ ensure_spec :: proc(checker: ^Checker, template: int, actual_args: []types.Type)
|
||||
}
|
||||
}
|
||||
result := type_from_syntax(function.result)
|
||||
if function.pkg == 0 && function.name == "main" && function.result == .Int {
|
||||
if function.pkg == 0 && function.name == checker.main_symbol && function.result == .Int {
|
||||
result = types.I32
|
||||
}
|
||||
index := len(checker.specs)
|
||||
@@ -401,8 +409,8 @@ infer_expr :: proc(checker: ^Checker, expr_id: int, locals: []Infer_Local, pkg :
|
||||
case .Integer:
|
||||
return types.smallest_signed_for_literal(expr.integer)
|
||||
case .Name:
|
||||
if expr.qualifier == "" {
|
||||
local_type := find_infer_local(locals, expr.text)
|
||||
if !symbol.is_valid(expr.qualifier) {
|
||||
local_type := find_infer_local(locals, expr.name)
|
||||
if types.is_valid(local_type) {
|
||||
return local_type
|
||||
}
|
||||
@@ -411,7 +419,7 @@ infer_expr :: proc(checker: ^Checker, expr_id: int, locals: []Infer_Local, pkg :
|
||||
if !available {
|
||||
return types.INVALID
|
||||
}
|
||||
global := find_global(checker, expr.text, target_pkg)
|
||||
global := find_global(checker, expr.name, target_pkg)
|
||||
if global >= 0 {
|
||||
return checker.global_types[global]
|
||||
}
|
||||
@@ -425,7 +433,7 @@ infer_expr :: proc(checker: ^Checker, expr_id: int, locals: []Infer_Local, pkg :
|
||||
if !available {
|
||||
return types.INVALID
|
||||
}
|
||||
template := find_template(checker, expr.text, target_pkg)
|
||||
template := find_template(checker, expr.name, target_pkg)
|
||||
if template < 0 {
|
||||
return types.INVALID
|
||||
}
|
||||
@@ -437,7 +445,7 @@ infer_expr :: proc(checker: ^Checker, expr_id: int, locals: []Infer_Local, pkg :
|
||||
if !can_specialize(function, args) {
|
||||
delete(args, checker.allocator)
|
||||
declared := type_from_syntax(function.result)
|
||||
if function.pkg == 0 && function.name == "main" && function.result == .Int {
|
||||
if function.pkg == 0 && function.name == checker.main_symbol && function.result == .Int {
|
||||
return types.I32
|
||||
}
|
||||
if declared.kind == .Concrete || declared.kind == .Void {
|
||||
@@ -456,7 +464,7 @@ infer_spec_result :: proc(checker: ^Checker, spec_id: int) -> types.Type {
|
||||
spec := checker.specs[spec_id]
|
||||
function := checker.ast_module.functions[spec.template]
|
||||
declared := type_from_syntax(function.result)
|
||||
if function.pkg == 0 && function.name == "main" && function.result == .Int {
|
||||
if function.pkg == 0 && function.name == checker.main_symbol && function.result == .Int {
|
||||
declared = types.I32
|
||||
}
|
||||
|
||||
@@ -525,7 +533,7 @@ infer_all :: proc(checker: ^Checker) {
|
||||
}
|
||||
}
|
||||
|
||||
main_template := find_template(checker, "main", 0)
|
||||
main_template := find_template(checker, checker.main_symbol, 0)
|
||||
if main_template >= 0 {
|
||||
ensure_spec(checker, main_template, nil)
|
||||
}
|
||||
@@ -588,7 +596,7 @@ add_unique :: proc(values: ^[dynamic]int, value: int) {
|
||||
append(values, value)
|
||||
}
|
||||
|
||||
find_build_local :: proc(locals: []Build_Local, name: string) -> (Build_Local, bool) {
|
||||
find_build_local :: proc(locals: []Build_Local, name: symbol.Id) -> (Build_Local, bool) {
|
||||
for index := len(locals) - 1; index >= 0; index -= 1 {
|
||||
if locals[index].name == name {
|
||||
return locals[index], true
|
||||
@@ -708,8 +716,8 @@ build_expr :: proc(
|
||||
case .Integer:
|
||||
unreachable()
|
||||
case .Name:
|
||||
if expr.qualifier == "" {
|
||||
if local, ok := find_build_local(locals, expr.text); ok {
|
||||
if !symbol.is_valid(expr.qualifier) {
|
||||
if local, ok := find_build_local(locals, expr.name); ok {
|
||||
return add_hir_expr(
|
||||
checker,
|
||||
hir.Expr {
|
||||
@@ -729,7 +737,7 @@ build_expr :: proc(
|
||||
id := add_package_resolution_diagnostic(checker, expr, file)
|
||||
return invalid_hir_expr(checker, expr.span, id)
|
||||
}
|
||||
global := find_global(checker, expr.text, target_pkg)
|
||||
global := find_global(checker, expr.name, target_pkg)
|
||||
if global >= 0 {
|
||||
add_unique(global_reads, global)
|
||||
return add_hir_expr(
|
||||
@@ -781,7 +789,7 @@ build_expr :: proc(
|
||||
id := add_package_resolution_diagnostic(checker, expr, file)
|
||||
return invalid_hir_expr(checker, expr.span, id)
|
||||
}
|
||||
template := find_template(checker, expr.text, target_pkg)
|
||||
template := find_template(checker, expr.name, target_pkg)
|
||||
if template < 0 {
|
||||
id := add_call_resolution_diagnostic(checker, expr, target_pkg)
|
||||
return invalid_hir_expr(checker, expr.span, id)
|
||||
@@ -791,7 +799,7 @@ build_expr :: proc(
|
||||
checker.diagnostics,
|
||||
expr.span,
|
||||
"function '%s' expects %d arguments, got %d",
|
||||
expr.text,
|
||||
symbol_text(checker, expr.name),
|
||||
len(checker.ast_module.functions[template].params),
|
||||
len(expr.args),
|
||||
)
|
||||
@@ -833,7 +841,7 @@ build_expr :: proc(
|
||||
checker.diagnostics,
|
||||
expr.span,
|
||||
"could not resolve result type for specialization of '%s'",
|
||||
expr.text,
|
||||
symbol_text(checker, expr.name),
|
||||
)
|
||||
delete(built_args, checker.allocator)
|
||||
return invalid_hir_expr(checker, expr.span, id)
|
||||
@@ -862,14 +870,14 @@ build_expr :: proc(
|
||||
make_link_name :: proc(checker: ^Checker, spec_id: int) -> string {
|
||||
spec := checker.specs[spec_id]
|
||||
function := checker.ast_module.functions[spec.template]
|
||||
if function.pkg == 0 && function.name == "main" {
|
||||
if function.pkg == 0 && function.name == checker.main_symbol {
|
||||
return fmt.aprintf("main", allocator = checker.allocator)
|
||||
}
|
||||
builder := strings.builder_make(checker.allocator)
|
||||
defer strings.builder_destroy(&builder)
|
||||
strings.write_string(&builder, "bro_c__" if function.c_abi else "bro__")
|
||||
fmt.sbprintf(&builder, "p%d__", function.pkg)
|
||||
strings.write_string(&builder, function.name)
|
||||
strings.write_string(&builder, symbol_text(checker, function.name))
|
||||
for arg in spec.args {
|
||||
strings.write_string(&builder, "__")
|
||||
strings.write_string(&builder, types.name(arg))
|
||||
@@ -891,7 +899,7 @@ build_function :: proc(checker: ^Checker, spec_id: int) {
|
||||
checker.diagnostics,
|
||||
function.span,
|
||||
"could not resolve a concrete result type for '%s'",
|
||||
function.name,
|
||||
symbol_text(checker, function.name),
|
||||
)
|
||||
}
|
||||
for arg in spec.args {
|
||||
@@ -900,7 +908,7 @@ build_function :: proc(checker: ^Checker, spec_id: int) {
|
||||
checker.diagnostics,
|
||||
function.span,
|
||||
"could not resolve a concrete parameter type for '%s'",
|
||||
function.name,
|
||||
symbol_text(checker, function.name),
|
||||
)
|
||||
break
|
||||
}
|
||||
@@ -984,7 +992,7 @@ build_function :: proc(checker: ^Checker, spec_id: int) {
|
||||
checker.diagnostics,
|
||||
statement.span,
|
||||
"duplicate local '%s'",
|
||||
statement.name,
|
||||
symbol_text(checker, statement.name),
|
||||
)
|
||||
append(&body, len(checker.module.statements))
|
||||
append(
|
||||
@@ -1031,7 +1039,7 @@ build_function :: proc(checker: ^Checker, spec_id: int) {
|
||||
)
|
||||
problematic = problematic || checker.module.exprs[value].kind == .Invalid
|
||||
case .Assignment:
|
||||
if statement.name == "_" {
|
||||
if statement.name == checker.sink_symbol {
|
||||
value := build_expr(checker, statement.expr, locals[:], &global_reads, &calls, types.INVALID, function.pkg, function.file)
|
||||
if checker.module.exprs[value].type.kind == .Void {
|
||||
id := source.add(
|
||||
@@ -1072,7 +1080,7 @@ build_function :: proc(checker: ^Checker, spec_id: int) {
|
||||
checker.diagnostics,
|
||||
statement.span,
|
||||
"cannot assign unresolved local '%s'",
|
||||
statement.name,
|
||||
symbol_text(checker, statement.name),
|
||||
)
|
||||
append(&body, len(checker.module.statements))
|
||||
append(
|
||||
@@ -1093,7 +1101,7 @@ build_function :: proc(checker: ^Checker, spec_id: int) {
|
||||
checker.diagnostics,
|
||||
statement.span,
|
||||
"cannot assign immutable local '%s'",
|
||||
statement.name,
|
||||
symbol_text(checker, statement.name),
|
||||
)
|
||||
append(&body, len(checker.module.statements))
|
||||
append(
|
||||
@@ -1265,7 +1273,7 @@ build_function :: proc(checker: ^Checker, spec_id: int) {
|
||||
checker.diagnostics,
|
||||
function.span,
|
||||
"function '%s' does not return a value",
|
||||
function.name,
|
||||
symbol_text(checker, function.name),
|
||||
)
|
||||
append(&body, len(checker.module.statements))
|
||||
append(
|
||||
@@ -1280,8 +1288,8 @@ build_function :: proc(checker: ^Checker, spec_id: int) {
|
||||
hir.Function {
|
||||
name = function.name,
|
||||
link_name = make_link_name(checker, spec_id),
|
||||
c_abi = function.c_abi || (function.pkg == 0 && function.name == "main"),
|
||||
is_main = function.pkg == 0 && function.name == "main",
|
||||
c_abi = function.c_abi || (function.pkg == 0 && function.name == checker.main_symbol),
|
||||
is_main = function.pkg == 0 && function.name == checker.main_symbol,
|
||||
params = params[:],
|
||||
result = spec.result,
|
||||
locals = hir_locals[:],
|
||||
@@ -1342,7 +1350,7 @@ build_globals :: proc(checker: ^Checker) {
|
||||
checker.diagnostics,
|
||||
global.span,
|
||||
"could not resolve a concrete type for global '%s'",
|
||||
global.name,
|
||||
symbol_text(checker, global.name),
|
||||
)
|
||||
global_type = types.I64
|
||||
expr = invalid_hir_expr(checker, global.span, diagnostic, global_type)
|
||||
@@ -1507,7 +1515,7 @@ detect_global_cycles_visit :: proc(checker: ^Checker, global_id: int, states: []
|
||||
checker.diagnostics,
|
||||
checker.ast_module.globals[global_id].span,
|
||||
"global initialization cycle involving '%s'",
|
||||
checker.module.globals[global_id].name,
|
||||
symbol_text(checker, checker.module.globals[global_id].name),
|
||||
)
|
||||
checker.module.globals[global_id].diagnostic = id
|
||||
checker.module.globals[global_id].problematic = true
|
||||
@@ -1537,7 +1545,7 @@ synthesize_trap_main :: proc(checker: ^Checker) {
|
||||
append(
|
||||
&checker.module.functions,
|
||||
hir.Function {
|
||||
name = "main",
|
||||
name = checker.main_symbol,
|
||||
link_name = fmt.aprintf("main", allocator = checker.allocator),
|
||||
c_abi = true,
|
||||
is_main = true,
|
||||
@@ -1581,12 +1589,16 @@ replace_main_with_trap :: proc(checker: ^Checker, diagnostic: int) {
|
||||
check :: proc(
|
||||
ast_module: ^ast.Module,
|
||||
diagnostics: ^source.Diagnostics,
|
||||
symbols: ^symbol.Table,
|
||||
allocator := context.allocator,
|
||||
) -> hir.Module {
|
||||
checker := Checker {
|
||||
ast_module = ast_module,
|
||||
diagnostics = diagnostics,
|
||||
symbols = symbols,
|
||||
module = hir.init_module(allocator),
|
||||
main_symbol = symbol.intern(symbols, "main"),
|
||||
sink_symbol = symbol.intern(symbols, "_"),
|
||||
allocator = allocator,
|
||||
}
|
||||
checker.specs.allocator = allocator
|
||||
@@ -1608,19 +1620,19 @@ check :: proc(
|
||||
for function, index in ast_module.functions {
|
||||
for previous in ast_module.functions[:index] {
|
||||
if previous.pkg == function.pkg && previous.name == function.name {
|
||||
source.addf(diagnostics, function.span, "duplicate function '%s'", function.name)
|
||||
source.addf(diagnostics, function.span, "duplicate function '%s'", symbol_text(&checker, function.name))
|
||||
}
|
||||
}
|
||||
for global in ast_module.globals {
|
||||
if global.pkg == function.pkg && global.name == function.name {
|
||||
source.addf(diagnostics, function.span, "package declaration '%s' conflicts with a global", function.name)
|
||||
source.addf(diagnostics, function.span, "package declaration '%s' conflicts with a global", symbol_text(&checker, function.name))
|
||||
}
|
||||
}
|
||||
}
|
||||
for global, index in ast_module.globals {
|
||||
for previous in ast_module.globals[:index] {
|
||||
if previous.pkg == global.pkg && previous.name == global.name {
|
||||
source.addf(diagnostics, global.span, "duplicate global '%s'", global.name)
|
||||
source.addf(diagnostics, global.span, "duplicate global '%s'", symbol_text(&checker, global.name))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1634,10 +1646,10 @@ check :: proc(
|
||||
resolve_call_targets(&checker)
|
||||
propagate_global_reads(&checker)
|
||||
|
||||
main_template := find_template(&checker, "main", 0)
|
||||
main_template := find_template(&checker, checker.main_symbol, 0)
|
||||
main_declarations := 0
|
||||
for function in ast_module.functions {
|
||||
if function.pkg == 0 && function.name == "main" {
|
||||
if function.pkg == 0 && function.name == checker.main_symbol {
|
||||
main_declarations += 1
|
||||
}
|
||||
}
|
||||
@@ -1666,7 +1678,7 @@ check :: proc(
|
||||
propagate_problems(&checker)
|
||||
for import_item in ast_module.imports {
|
||||
if import_item.valid && !import_item.used {
|
||||
source.addf(diagnostics, import_item.span, "unused import '%s'", import_item.alias)
|
||||
source.addf(diagnostics, import_item.span, "unused import '%s'", symbol_text(&checker, import_item.alias))
|
||||
}
|
||||
}
|
||||
return checker.module
|
||||
|
||||
Reference in New Issue
Block a user