refactor: integrate compilation-owned identifier interning
This commit is contained in:
+123
-137
@@ -46,8 +46,8 @@ code_count proc(diagnostic_store @diagnostics.Store, code diagnostics.Code) usiz
|
||||
}
|
||||
|
||||
propagates_numeric_context_before_defaulting_forward_and_mutable_aliases test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -66,10 +66,10 @@ propagates_numeric_context_before_defaulting_forward_and_mutable_aliases test {
|
||||
`nested float :: quotient / (alias + 1)
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
@@ -102,8 +102,8 @@ propagates_numeric_context_before_defaulting_forward_and_mutable_aliases test {
|
||||
}
|
||||
|
||||
rejects_fixed_family_conversion_integer_division_and_conflicting_demands test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -124,10 +124,10 @@ rejects_fixed_family_conversion_integer_division_and_conflicting_demands test {
|
||||
`good :: 9
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
@@ -169,8 +169,8 @@ rejects_fixed_family_conversion_integer_division_and_conflicting_demands test {
|
||||
}
|
||||
|
||||
checks_forward_alias_calls_grouped_parameters_and_mutual_recursion test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -189,10 +189,10 @@ checks_forward_alias_calls_grouped_parameters_and_mutual_recursion test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -244,8 +244,8 @@ checks_forward_alias_calls_grouped_parameters_and_mutual_recursion test {
|
||||
}
|
||||
|
||||
separates_type_annotations_from_values_and_restricts_void_storage test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -266,10 +266,10 @@ separates_type_annotations_from_values_and_restricts_void_storage test {
|
||||
`good string :: "ok"
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
@@ -336,8 +336,8 @@ separates_type_annotations_from_values_and_restricts_void_storage test {
|
||||
}
|
||||
|
||||
reports_nonvoid_fallthrough_without_poisoning_signatures_and_checks_unused_bodies test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -353,10 +353,10 @@ reports_nonvoid_fallthrough_without_poisoning_signatures_and_checks_unused_bodie
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -391,8 +391,8 @@ reports_nonvoid_fallthrough_without_poisoning_signatures_and_checks_unused_bodie
|
||||
}
|
||||
|
||||
checks_arguments_even_for_wrong_arity_noncallable_and_chained_callees test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -410,10 +410,10 @@ checks_arguments_even_for_wrong_arity_noncallable_and_chained_callees test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -455,8 +455,8 @@ checks_arguments_even_for_wrong_arity_noncallable_and_chained_callees test {
|
||||
}
|
||||
|
||||
terminates_unanchored_cycles_and_keeps_grounded_cycles_typed test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -474,10 +474,10 @@ terminates_unanchored_cycles_and_keeps_grounded_cycles_typed test {
|
||||
`contextual_b :: contextual_a
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
@@ -530,8 +530,8 @@ terminates_unanchored_cycles_and_keeps_grounded_cycles_typed test {
|
||||
}
|
||||
|
||||
preserves_existing_syntax_name_and_duplicate_ids_while_checking_siblings test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -548,10 +548,10 @@ preserves_existing_syntax_name_and_duplicate_ids_while_checking_siblings test {
|
||||
`same :: -"initializer"
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
previous_count :: diagnostics.count(&diagnostic_store)
|
||||
function :: ast.package_decl(&tree, 1)
|
||||
@@ -608,8 +608,8 @@ preserves_existing_syntax_name_and_duplicate_ids_while_checking_siblings test {
|
||||
}
|
||||
|
||||
returns_supply_numeric_context_and_resolve_forward_local_and_parameter_names test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -624,10 +624,10 @@ returns_supply_numeric_context_and_resolve_forward_local_and_parameter_names tes
|
||||
`seed :: 3
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -666,8 +666,8 @@ returns_supply_numeric_context_and_resolve_forward_local_and_parameter_names tes
|
||||
}
|
||||
|
||||
return_errors_preserve_identity_check_unreachable_code_and_suppress_missing_return_cascades test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -687,10 +687,10 @@ return_errors_preserve_identity_check_unreachable_code_and_suppress_missing_retu
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -733,8 +733,8 @@ return_errors_preserve_identity_check_unreachable_code_and_suppress_missing_retu
|
||||
}
|
||||
|
||||
checks_bool_comparisons_recursive_returns_and_nested_numeric_context test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -769,10 +769,10 @@ checks_bool_comparisons_recursive_returns_and_nested_numeric_context test {
|
||||
`main proc() bool { return identity(flag) }
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -815,8 +815,8 @@ checks_bool_comparisons_recursive_returns_and_nested_numeric_context test {
|
||||
}
|
||||
|
||||
rejects_bool_numeric_mixing_and_preserves_invalid_condition_identity test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -835,10 +835,10 @@ rejects_bool_numeric_mixing_and_preserves_invalid_condition_identity test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -882,8 +882,8 @@ rejects_bool_numeric_mixing_and_preserves_invalid_condition_identity test {
|
||||
}
|
||||
|
||||
analyzes_return_paths_after_trap_propagation_without_poisoning_signatures test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -918,10 +918,10 @@ analyzes_return_paths_after_trap_propagation_without_poisoning_signatures test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -970,8 +970,8 @@ analyzes_return_paths_after_trap_propagation_without_poisoning_signatures test {
|
||||
}
|
||||
|
||||
assignments_preserve_established_types_and_contextualize_numeric_values test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -996,10 +996,10 @@ assignments_preserve_established_types_and_contextualize_numeric_values test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
@@ -1065,8 +1065,8 @@ assignments_preserve_established_types_and_contextualize_numeric_values test {
|
||||
}
|
||||
|
||||
assignment_target_errors_preserve_bindings_and_independent_rhs_diagnostics test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1084,10 +1084,10 @@ assignment_target_errors_preserve_bindings_and_independent_rhs_diagnostics test
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1124,8 +1124,8 @@ assignment_target_errors_preserve_bindings_and_independent_rhs_diagnostics test
|
||||
}
|
||||
|
||||
function_assignment_checks_complete_signatures_without_retargeting_calls test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1145,10 +1145,10 @@ function_assignment_checks_complete_signatures_without_retargeting_calls test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
@@ -1178,8 +1178,8 @@ function_assignment_checks_complete_signatures_without_retargeting_calls test {
|
||||
}
|
||||
|
||||
while_checks_nested_bodies_without_claiming_a_zero_iteration_return test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1203,10 +1203,10 @@ while_checks_nested_bodies_without_claiming_a_zero_iteration_return test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1251,8 +1251,8 @@ while_checks_nested_bodies_without_claiming_a_zero_iteration_return test {
|
||||
}
|
||||
|
||||
logical_types_preserve_comparison_context_and_assignment_isolation test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1270,10 +1270,10 @@ logical_types_preserve_comparison_context_and_assignment_isolation test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1316,8 +1316,8 @@ logical_types_preserve_comparison_context_and_assignment_isolation test {
|
||||
}
|
||||
|
||||
logical_operand_errors_are_independent_and_skipped_rhs_preserves_bool test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1342,10 +1342,10 @@ logical_operand_errors_are_independent_and_skipped_rhs_preserves_bool test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1412,8 +1412,8 @@ logical_operand_errors_are_independent_and_skipped_rhs_preserves_bool test {
|
||||
}
|
||||
|
||||
logical_external_mismatches_and_always_demanded_not_preserve_errors test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1435,10 +1435,10 @@ logical_external_mismatches_and_always_demanded_not_preserve_errors test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1491,8 +1491,8 @@ logical_external_mismatches_and_always_demanded_not_preserve_errors test {
|
||||
}
|
||||
|
||||
short_circuit_skip_paths_do_not_guarantee_a_return test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1514,10 +1514,10 @@ short_circuit_skip_paths_do_not_guarantee_a_return test {
|
||||
`take proc(value bool) void {}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1550,8 +1550,8 @@ short_circuit_skip_paths_do_not_guarantee_a_return test {
|
||||
}
|
||||
|
||||
loop_controls_follow_lexical_bodies_and_check_unreachable_code test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1583,10 +1583,10 @@ loop_controls_follow_lexical_bodies_and_check_unreachable_code test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1639,8 +1639,8 @@ loop_controls_follow_lexical_bodies_and_check_unreachable_code test {
|
||||
}
|
||||
|
||||
loop_controls_do_not_guarantee_function_returns test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1661,10 +1661,10 @@ loop_controls_do_not_guarantee_function_returns test {
|
||||
`invalid proc() int { break }
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1694,8 +1694,8 @@ loop_controls_do_not_guarantee_function_returns test {
|
||||
}
|
||||
|
||||
range_bounds_receive_integer_context_without_joining_the_range_or_capture test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1714,10 +1714,10 @@ range_bounds_receive_integer_context_without_joining_the_range_or_capture test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1753,8 +1753,8 @@ range_bounds_receive_integer_context_without_joining_the_range_or_capture test {
|
||||
}
|
||||
|
||||
range_checks_both_bounds_and_preserves_fixed_declarations_and_source_errors test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1776,10 +1776,10 @@ range_checks_both_bounds_and_preserves_fixed_declarations_and_source_errors test
|
||||
`flexible := 3
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1826,8 +1826,8 @@ range_checks_both_bounds_and_preserves_fixed_declarations_and_source_errors test
|
||||
}
|
||||
|
||||
range_values_nonrange_iterables_and_capture_modes_have_explicit_errors test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1851,10 +1851,10 @@ range_values_nonrange_iterables_and_capture_modes_have_explicit_errors test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1901,8 +1901,8 @@ range_values_nonrange_iterables_and_capture_modes_have_explicit_errors test {
|
||||
}
|
||||
|
||||
range_captures_are_fixed_readonly_and_assignment_values_do_not_retarget_bounds test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -1927,10 +1927,10 @@ range_captures_are_fixed_readonly_and_assignment_values_do_not_retarget_bounds t
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -1986,8 +1986,8 @@ range_captures_are_fixed_readonly_and_assignment_values_do_not_retarget_bounds t
|
||||
}
|
||||
|
||||
range_loop_return_flow_and_controls_are_lexical_and_body_errors_are_isolated test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -2025,10 +2025,10 @@ range_loop_return_flow_and_controls_are_lexical_and_body_errors_are_isolated tes
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
defer deinit(&result)
|
||||
@@ -2080,8 +2080,8 @@ range_loop_return_flow_and_controls_are_lexical_and_body_errors_are_isolated tes
|
||||
}
|
||||
|
||||
invalid_range_capture_bindings_keep_resolver_diagnostic_ids_without_erasing_headers test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -2094,10 +2094,10 @@ invalid_range_capture_bindings_keep_resolver_diagnostic_ids_without_erasing_head
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &strings, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &diagnostic_store)
|
||||
defer sema.deinit(&resolution)
|
||||
previous_count :: diagnostics.count(&diagnostic_store)
|
||||
result := try check(mem.c_allocator, &tree, &resolution, &diagnostic_store)
|
||||
@@ -2132,6 +2132,7 @@ invalid_range_capture_bindings_keep_resolver_diagnostic_ids_without_erasing_head
|
||||
|
||||
@hide:file
|
||||
ArrayFixture :: struct {
|
||||
strings strpool.StringPool
|
||||
tree ast.Tree
|
||||
resolution sema.Resolution
|
||||
diagnostics diagnostics.Store
|
||||
@@ -2140,17 +2141,19 @@ ArrayFixture :: struct {
|
||||
|
||||
@hide:file
|
||||
array_fixture proc(source []u8) ArrayFixture ! (mem.AllocError | strpool.InternError | diagnostics.CapacityError | lexer.SourceError) {
|
||||
strings := strpool.init(mem.c_allocator)
|
||||
errdefer strpool.deinit(&strings)
|
||||
store := diagnostics.init(mem.c_allocator)
|
||||
errdefer diagnostics.deinit(&store)
|
||||
scan := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan)
|
||||
try lexer.scan(&scan, source, &store)
|
||||
try lexer.scan(&scan, source, &strings, &store)
|
||||
tree := try parser.parse(mem.c_allocator, scan.tokens.items, source, &store)
|
||||
errdefer ast.deinit(&tree)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &store)
|
||||
resolution := try sema.resolve(mem.c_allocator, &tree, &strings, &store)
|
||||
errdefer sema.deinit(&resolution)
|
||||
result :: try check(mem.c_allocator, &tree, &resolution, &store)
|
||||
return ArrayFixture{ tree = tree, resolution = resolution, diagnostics = store, result = result }
|
||||
return ArrayFixture{ strings = strings, tree = tree, resolution = resolution, diagnostics = store, result = result }
|
||||
}
|
||||
|
||||
@hide:file
|
||||
@@ -2159,6 +2162,7 @@ deinit_array_fixture proc(fixture @mut ArrayFixture) void {
|
||||
sema.deinit(&fixture.resolution)
|
||||
ast.deinit(&fixture.tree)
|
||||
diagnostics.deinit(&fixture.diagnostics)
|
||||
strpool.deinit(&fixture.strings)
|
||||
}
|
||||
|
||||
@hide:file
|
||||
@@ -2172,8 +2176,6 @@ expect_array proc(result @Result, id ast.NodeId, len usize, mutable bool, elemen
|
||||
}
|
||||
|
||||
fixed_arrays_contextualize_forward_aliases_counts_nested_literals_and_signatures test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
source ::
|
||||
`context [2]f64 :: alias
|
||||
`alias :: seed
|
||||
@@ -2225,8 +2227,6 @@ fixed_arrays_contextualize_forward_aliases_counts_nested_literals_and_signatures
|
||||
}
|
||||
|
||||
nested_array_numeric_context_flows_through_index_children_before_defaults test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
source ::
|
||||
`first float :: later[0][0]
|
||||
`later := [[1, 2], [3, 4]]
|
||||
@@ -2262,8 +2262,6 @@ nested_array_numeric_context_flows_through_index_children_before_defaults test {
|
||||
}
|
||||
|
||||
fixed_index_errors_are_occurrence_local_and_preserve_sources_and_siblings test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
source ::
|
||||
`fixed i64 :: 0
|
||||
`inferred := 0
|
||||
@@ -2298,8 +2296,6 @@ fixed_index_errors_are_occurrence_local_and_preserve_sources_and_siblings test {
|
||||
}
|
||||
|
||||
array_lengths_require_supported_constexpr_and_finalize_nested_inferred_counts test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
source ::
|
||||
`two :: tail
|
||||
`tail :: 2
|
||||
@@ -2355,8 +2351,6 @@ array_lengths_require_supported_constexpr_and_finalize_nested_inferred_counts te
|
||||
}
|
||||
|
||||
indexed_writes_require_mutable_local_root_and_each_array_level_but_copies_are_values test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
source ::
|
||||
`global [1]mut i64 := [1]
|
||||
`main proc(parameter [1]mut i64) void {
|
||||
@@ -2408,8 +2402,6 @@ indexed_writes_require_mutable_local_root_and_each_array_level_but_copies_are_va
|
||||
}
|
||||
|
||||
usize_arithmetic_ranges_and_readonly_captures_keep_the_bound_family test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
source ::
|
||||
`limit usize :: 18446744073709551615
|
||||
`arithmetic usize :: (limit - 2) * 1 + 1
|
||||
@@ -2470,8 +2462,6 @@ usize_arithmetic_ranges_and_readonly_captures_keep_the_bound_family test {
|
||||
}
|
||||
|
||||
array_assignment_rhs_is_contextual_but_does_not_retarget_established_sources test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
source ::
|
||||
`main proc() void {
|
||||
` target [2]mut f64 := [1, 2]
|
||||
@@ -2513,8 +2503,6 @@ array_assignment_rhs_is_contextual_but_does_not_retarget_established_sources tes
|
||||
}
|
||||
|
||||
array_signature_identity_includes_recursive_counts_and_mutability test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
source ::
|
||||
`accept proc(value [1]mut i64) [1]mut i64 { return value }
|
||||
`different_count proc(value [2]mut i64) [1]mut i64 { return [1] }
|
||||
@@ -2559,8 +2547,6 @@ array_signature_identity_includes_recursive_counts_and_mutability test {
|
||||
}
|
||||
|
||||
inferred_counts_follow_forward_fixed_aliases_empty_shapes_and_reject_local_counts test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
source ::
|
||||
`forward [_]i64 :: later
|
||||
`later [_]i64 :: [1, 2]
|
||||
|
||||
+63
-27
@@ -1,7 +1,7 @@
|
||||
import "@std/debug"
|
||||
import "@std/mem"
|
||||
import "@std/hashmap"
|
||||
import "@std/strmap"
|
||||
import "@source/strpool"
|
||||
|
||||
import "@source/ast"
|
||||
import "@source/diagnostics"
|
||||
@@ -14,16 +14,22 @@ BuiltinType :: enum {
|
||||
}
|
||||
|
||||
@hide:file
|
||||
builtins strmap.StaticStringMap(BuiltinType) :: strmap.init([
|
||||
{ "int", .int },
|
||||
{ "float", .float },
|
||||
{ "bool", .bool },
|
||||
{ "string", .string },
|
||||
{ "void", .void },
|
||||
{ "i64", .i64 },
|
||||
{ "f64", .f64 },
|
||||
{ "usize", .usize },
|
||||
])
|
||||
Builtin :: struct {
|
||||
name []u8
|
||||
type BuiltinType
|
||||
}
|
||||
|
||||
@hide:file
|
||||
builtins [8]Builtin :: [
|
||||
{ name = "int", type = .int },
|
||||
{ name = "float", type = .float },
|
||||
{ name = "bool", type = .bool },
|
||||
{ name = "string", type = .string },
|
||||
{ name = "void", type = .void },
|
||||
{ name = "i64", type = .i64 },
|
||||
{ name = "f64", type = .f64 },
|
||||
{ name = "usize", type = .usize },
|
||||
]
|
||||
|
||||
BindingKind :: enum { none, declaration, builtin, invalid }
|
||||
|
||||
@@ -50,7 +56,7 @@ Resolution :: struct { storage Storage }
|
||||
|
||||
@hide:file
|
||||
Scope :: struct {
|
||||
names hashmap.StringHashMap(Binding)
|
||||
names hashmap.HashMap(strpool.StringId, Binding, name_hash, names_equal)
|
||||
parent ?@Scope
|
||||
}
|
||||
|
||||
@@ -59,17 +65,19 @@ State :: struct {
|
||||
tree @ast.Tree
|
||||
diagnostics @mut diagnostics.Store
|
||||
bindings []mut Binding
|
||||
builtin_ids [8]mut strpool.StringId = [0, 0, 0, 0, 0, 0, 0, 0]
|
||||
allocator mem.Allocator
|
||||
}
|
||||
|
||||
#! borrows `tree` and `diagnostic_store` during resolution, without retaining their storage.
|
||||
#! borrows `tree`, its identifier `pool`, and `diagnostic_store` during resolution.
|
||||
#! `allocator` supplies caller-owned bindings and temporary scopes released before return.
|
||||
#! release the returned Resolution with deinit, which uses the retained allocator.
|
||||
resolve proc(
|
||||
allocator mem.Allocator,
|
||||
tree @ast.Tree,
|
||||
pool @mut strpool.StringPool,
|
||||
diagnostic_store @mut diagnostics.Store,
|
||||
) Resolution ! (mem.AllocError | diagnostics.CapacityError) {
|
||||
) Resolution ! (mem.AllocError | strpool.InternError | diagnostics.CapacityError) {
|
||||
bindings :: try mem.alloc(Binding, allocator, ast.node_count(tree))
|
||||
errdefer mem.free(allocator, bindings)
|
||||
mem.set(bindings, Binding{})
|
||||
@@ -81,7 +89,13 @@ resolve proc(
|
||||
allocator = allocator,
|
||||
}
|
||||
|
||||
package_scope := Scope{ names = hashmap.init(allocator), parent = null }
|
||||
for (builtins) |builtin, index| {
|
||||
state.builtin_ids[index] = try strpool.intern(pool, builtin.name)
|
||||
}
|
||||
package_scope := Scope{
|
||||
names = hashmap.init(strpool.StringId, Binding, name_hash, names_equal, allocator),
|
||||
parent = null,
|
||||
}
|
||||
defer hashmap.deinit(&package_scope.names)
|
||||
for (0..ast.package_decl_count(tree)) |i| {
|
||||
id :: ast.package_decl(tree, i)
|
||||
@@ -115,19 +129,22 @@ binding proc(resolution @Resolution, id ast.NodeId) Binding {
|
||||
}
|
||||
|
||||
@hide:file
|
||||
lookup proc(scope ?@Scope, name []u8) ?Binding {
|
||||
lookup proc(state @State, scope ?@Scope, name strpool.StringId) ?Binding {
|
||||
if scope |current| {
|
||||
if hashmap.get(¤t.names, name) |found| return found
|
||||
return lookup(current.parent, name)
|
||||
return lookup(state, current.parent, name)
|
||||
}
|
||||
if strmap.get(&builtins, name) |type| {
|
||||
return Binding{ kind = .builtin, data = BindingData{ builtin = type } }
|
||||
for (state.builtin_ids) |id, index| {
|
||||
if (id == name) return Binding{
|
||||
kind = .builtin,
|
||||
data = BindingData{ builtin = builtins[index].type },
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@hide:file
|
||||
put_name proc(scope @mut Scope, name []u8, value Binding) void ! mem.AllocError {
|
||||
put_name proc(scope @mut Scope, name strpool.StringId, value Binding) void ! mem.AllocError {
|
||||
hashmap.put(&scope.names, name, value) catch |err| {
|
||||
match err {
|
||||
.key_exists: unreachable
|
||||
@@ -143,7 +160,7 @@ predeclare proc(
|
||||
id ast.NodeId,
|
||||
name_span ast.Span,
|
||||
) void ! (mem.AllocError | diagnostics.CapacityError) {
|
||||
name :: ast.source_text(state.tree, name_span)
|
||||
name :: ast.name_id(state.tree, id)
|
||||
if hashmap.get(&scope.names, name) |_| {
|
||||
diagnostic :: try diagnostics.add(state.diagnostics, .duplicate_name, name_span)
|
||||
state.bindings[usize(id)] = Binding{
|
||||
@@ -154,7 +171,7 @@ predeclare proc(
|
||||
}
|
||||
|
||||
value := Binding{ kind = .declaration, data = BindingData{ declaration = id } }
|
||||
if lookup(scope.parent, name) |_| {
|
||||
if lookup(state, scope.parent, name) |_| {
|
||||
diagnostic :: try diagnostics.add(state.diagnostics, .duplicate_name, name_span)
|
||||
# poison the inner name rather than silently binding uses to its ancestor.
|
||||
value = Binding{ kind = .invalid, data = BindingData{ diagnostic = diagnostic } }
|
||||
@@ -178,7 +195,10 @@ resolve_function proc(
|
||||
try resolve_expr(state, package_scope, ast.param(tree, parameter).type)
|
||||
}
|
||||
|
||||
scope := Scope{ names = hashmap.init(state.allocator), parent = package_scope }
|
||||
scope := Scope{
|
||||
names = hashmap.init(strpool.StringId, Binding, name_hash, names_equal, state.allocator),
|
||||
parent = package_scope,
|
||||
}
|
||||
defer hashmap.deinit(&scope.names)
|
||||
for (0..ast.function_param_count(tree, id)) |i| {
|
||||
parameter :: ast.function_param(tree, id, i)
|
||||
@@ -189,7 +209,10 @@ resolve_function proc(
|
||||
|
||||
@hide:file
|
||||
resolve_arm proc(state @mut State, parent @Scope, id ast.NodeId) void ! (mem.AllocError | diagnostics.CapacityError) {
|
||||
scope := Scope{ names = hashmap.init(state.allocator), parent = parent }
|
||||
scope := Scope{
|
||||
names = hashmap.init(strpool.StringId, Binding, name_hash, names_equal, state.allocator),
|
||||
parent = parent,
|
||||
}
|
||||
defer hashmap.deinit(&scope.names)
|
||||
try resolve_block(state, &scope, id)
|
||||
}
|
||||
@@ -231,7 +254,10 @@ resolve_block proc(state @mut State, scope @mut Scope, id ast.NodeId) void ! (me
|
||||
.for_stmt: {
|
||||
loop :: ast.for_stmt(tree, statement)
|
||||
try resolve_expr(state, scope, loop.iterable)
|
||||
body_scope := Scope{ names = hashmap.init(state.allocator), parent = scope }
|
||||
body_scope := Scope{
|
||||
names = hashmap.init(strpool.StringId, Binding, name_hash, names_equal, state.allocator),
|
||||
parent = scope,
|
||||
}
|
||||
defer hashmap.deinit(&body_scope.names)
|
||||
if (loop.capture) |capture| {
|
||||
try predeclare(state, &body_scope, capture, ast.node_span(tree, capture))
|
||||
@@ -279,8 +305,8 @@ resolve_expr proc(
|
||||
.literal_int, .literal_float, .literal_bool, .literal_string: {}
|
||||
.identifier: {
|
||||
span :: ast.node_span(tree, id)
|
||||
name :: ast.source_text(tree, span)
|
||||
if lookup(scope, name) |found| {
|
||||
name :: ast.name_id(tree, id)
|
||||
if lookup(state, scope, name) |found| {
|
||||
state.bindings[usize(id)] = found
|
||||
} else {
|
||||
diagnostic :: try diagnostics.add(state.diagnostics, .unknown_name, span)
|
||||
@@ -325,3 +351,13 @@ resolve_expr proc(
|
||||
.invalid: resolve_invalid(state, id)
|
||||
}
|
||||
}
|
||||
|
||||
@hide:file
|
||||
name_hash proc(name strpool.StringId) usize {
|
||||
return usize(name)
|
||||
}
|
||||
|
||||
@hide:file
|
||||
names_equal proc(left, right strpool.StringId) bool {
|
||||
return left == right
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import "@source/parser"
|
||||
import "@source/ast"
|
||||
|
||||
resolves_forward_references_recursion_and_builtin_signatures test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -25,10 +25,10 @@ resolves_forward_references_recursion_and_builtin_signatures test {
|
||||
`later int :: 1
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
|
||||
first :: ast.package_decl(&tree, 0)
|
||||
@@ -110,8 +110,8 @@ resolves_forward_references_recursion_and_builtin_signatures test {
|
||||
}
|
||||
|
||||
rejects_shadowing_and_duplicates_without_cascades test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -132,11 +132,11 @@ rejects_shadowing_and_duplicates_without_cascades test {
|
||||
`same :: same
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
|
||||
function :: ast.package_decl(&tree, 0)
|
||||
@@ -228,8 +228,8 @@ rejects_shadowing_and_duplicates_without_cascades test {
|
||||
}
|
||||
|
||||
preserves_syntax_diagnostics_and_resolves_shared_unknown_types_once test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -243,7 +243,7 @@ preserves_syntax_diagnostics_and_resolves_shared_unknown_types_once test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
syntax_count :: diagnostics.count(&diagnostic_store)
|
||||
@@ -255,7 +255,7 @@ preserves_syntax_diagnostics_and_resolves_shared_unknown_types_once test {
|
||||
try testing.expect_equal(ast.ExprKind.invalid, ast.expr_kind(&tree, empty))
|
||||
invalid_statement :: ast.block_statement(&tree, view.body, 4)
|
||||
try testing.expect_equal(ast.StmtKind.invalid, ast.stmt_kind(&tree, invalid_statement))
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
|
||||
invalid_nodes [3]ast.NodeId :: [invalid_decl, empty, invalid_statement]
|
||||
@@ -300,8 +300,8 @@ preserves_syntax_diagnostics_and_resolves_shared_unknown_types_once test {
|
||||
}
|
||||
|
||||
resolves_conditional_arm_scopes_without_leaks_or_shadowing test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -323,11 +323,11 @@ resolves_conditional_arm_scopes_without_leaks_or_shadowing test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
|
||||
function :: ast.package_decl(&tree, 0)
|
||||
@@ -368,8 +368,8 @@ resolves_conditional_arm_scopes_without_leaks_or_shadowing test {
|
||||
}
|
||||
|
||||
resolves_loop_assignments_in_lexical_scopes_with_forward_local_bindings test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -394,11 +394,11 @@ resolves_loop_assignments_in_lexical_scopes_with_forward_local_bindings test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
|
||||
function :: ast.package_decl(&tree, 0)
|
||||
@@ -441,8 +441,8 @@ resolves_loop_assignments_in_lexical_scopes_with_forward_local_bindings test {
|
||||
}
|
||||
|
||||
resolves_all_code_and_preserves_scopes_after_loop_controls test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -464,11 +464,11 @@ resolves_all_code_and_preserves_scopes_after_loop_controls test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
try testing.expect_equal(4, diagnostics.count(&diagnostic_store))
|
||||
body :: ast.function_decl(&tree, ast.package_decl(&tree, 0)).body
|
||||
@@ -487,8 +487,8 @@ resolves_all_code_and_preserves_scopes_after_loop_controls test {
|
||||
}
|
||||
|
||||
range_bounds_use_outer_scope_and_captures_are_body_declarations test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -506,10 +506,10 @@ range_bounds_use_outer_scope_and_captures_are_body_declarations test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
body :: ast.function_decl(&tree, ast.package_decl(&tree, 0)).body
|
||||
loop :: ast.for_stmt(&tree, ast.block_statement(&tree, body, 0))
|
||||
@@ -540,8 +540,8 @@ range_bounds_use_outer_scope_and_captures_are_body_declarations test {
|
||||
}
|
||||
|
||||
range_captures_preserve_duplicate_builtin_and_discard_errors test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -563,10 +563,10 @@ range_captures_preserve_duplicate_builtin_and_discard_errors test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
body :: ast.function_decl(&tree, ast.package_decl(&tree, 0)).body
|
||||
for (usize(1)..usize(3)) |index| {
|
||||
@@ -605,8 +605,8 @@ range_captures_preserve_duplicate_builtin_and_discard_errors test {
|
||||
}
|
||||
|
||||
resolves_array_counts_elements_indices_and_unreachable_targets test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -621,10 +621,10 @@ resolves_array_counts_elements_indices_and_unreachable_targets test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
size :: ast.package_decl(&tree, 0)
|
||||
@@ -669,8 +669,8 @@ resolves_array_counts_elements_indices_and_unreachable_targets test {
|
||||
}
|
||||
|
||||
array_signature_counts_use_package_scope_and_local_counts_see_parameters test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -682,11 +682,11 @@ array_signature_counts_use_package_scope_and_local_counts_see_parameters test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
try testing.expect_equal(2, diagnostics.count(&diagnostic_store))
|
||||
function :: ast.package_decl(&tree, 1)
|
||||
@@ -710,8 +710,8 @@ array_signature_counts_use_package_scope_and_local_counts_see_parameters test {
|
||||
}
|
||||
|
||||
resolves_every_array_child_error_and_preserves_lexer_diagnostics test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&pool)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
source ::
|
||||
@@ -723,11 +723,11 @@ resolves_every_array_child_error_and_preserves_lexer_diagnostics test {
|
||||
`}
|
||||
scan_state := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&scan_state)
|
||||
try lexer.scan(&scan_state, source, &diagnostic_store)
|
||||
try lexer.scan(&scan_state, source, &pool, &diagnostic_store)
|
||||
tree := try parser.parse(mem.c_allocator, scan_state.tokens.items, source, &diagnostic_store)
|
||||
defer ast.deinit(&tree)
|
||||
try testing.expect_equal(2, diagnostics.count(&diagnostic_store))
|
||||
resolution := try resolve(mem.c_allocator, &tree, &diagnostic_store)
|
||||
resolution := try resolve(mem.c_allocator, &tree, &pool, &diagnostic_store)
|
||||
defer deinit(&resolution)
|
||||
try testing.expect_equal(10, diagnostics.count(&diagnostic_store))
|
||||
body :: ast.function_decl(&tree, ast.package_decl(&tree, 0)).body
|
||||
@@ -755,3 +755,57 @@ resolves_every_array_child_error_and_preserves_lexer_diagnostics test {
|
||||
try testing.expect_equal(diagnostics.DiagnosticId(0), binding(&resolution, malformed_count).data.diagnostic)
|
||||
try testing.expect_equal(diagnostics.DiagnosticId(1), binding(&resolution, malformed_element).data.diagnostic)
|
||||
}
|
||||
|
||||
resolves_interleaved_compilations_with_independent_identifier_orders test {
|
||||
first_pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&first_pool)
|
||||
second_pool := strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&second_pool)
|
||||
first_diagnostics := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&first_diagnostics)
|
||||
second_diagnostics := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&second_diagnostics)
|
||||
first_source :: "alpha :: beta\nbeta i64 :: 1\nmain proc() bool { return true }\n"
|
||||
second_source :: "beta :: alpha\nalpha bool :: false\nmain proc() i64 { return 1 }\n"
|
||||
first_scan := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&first_scan)
|
||||
second_scan := lexer.init(mem.c_allocator)
|
||||
defer lexer.deinit(&second_scan)
|
||||
try lexer.scan(&first_scan, first_source, &first_pool, &first_diagnostics)
|
||||
first_tree := try parser.parse(mem.c_allocator, first_scan.tokens.items, first_source, &first_diagnostics)
|
||||
defer ast.deinit(&first_tree)
|
||||
try lexer.scan(&second_scan, second_source, &second_pool, &second_diagnostics)
|
||||
second_tree := try parser.parse(mem.c_allocator, second_scan.tokens.items, second_source, &second_diagnostics)
|
||||
defer ast.deinit(&second_tree)
|
||||
first_name :: ast.name_id(&first_tree, ast.package_decl(&first_tree, 0))
|
||||
second_name :: ast.name_id(&second_tree, ast.package_decl(&second_tree, 0))
|
||||
try testing.expect_equal(first_name, second_name)
|
||||
try testing.expect_equal("alpha", strpool.get_str(&first_pool, first_name)?)
|
||||
try testing.expect_equal("beta", strpool.get_str(&second_pool, second_name)?)
|
||||
first_resolution := try resolve(mem.c_allocator, &first_tree, &first_pool, &first_diagnostics)
|
||||
defer deinit(&first_resolution)
|
||||
second_resolution := try resolve(mem.c_allocator, &second_tree, &second_pool, &second_diagnostics)
|
||||
defer deinit(&second_resolution)
|
||||
first_decl :: ast.package_decl(&first_tree, 0)
|
||||
second_decl :: ast.package_decl(&second_tree, 0)
|
||||
first_target :: ast.package_decl(&first_tree, 1)
|
||||
second_target :: ast.package_decl(&second_tree, 1)
|
||||
first_use :: ast.statement_decl(&first_tree, first_decl).initializer
|
||||
second_use :: ast.statement_decl(&second_tree, second_decl).initializer
|
||||
try testing.expect_equal(BindingKind.declaration, binding(&first_resolution, first_use).kind)
|
||||
try testing.expect_equal(first_target, binding(&first_resolution, first_use).data.declaration)
|
||||
try testing.expect_equal(BindingKind.declaration, binding(&second_resolution, second_use).kind)
|
||||
try testing.expect_equal(second_target, binding(&second_resolution, second_use).data.declaration)
|
||||
first_type :: ast.statement_decl(&first_tree, first_target).type?
|
||||
second_type :: ast.statement_decl(&second_tree, second_target).type?
|
||||
try testing.expect_equal(BindingKind.builtin, binding(&first_resolution, first_type).kind)
|
||||
try testing.expect_equal(BuiltinType.i64, binding(&first_resolution, first_type).data.builtin)
|
||||
try testing.expect_equal(BindingKind.builtin, binding(&second_resolution, second_type).kind)
|
||||
try testing.expect_equal(BuiltinType.bool, binding(&second_resolution, second_type).data.builtin)
|
||||
first_return :: ast.function_decl(&first_tree, ast.package_decl(&first_tree, 2)).return_type
|
||||
second_return :: ast.function_decl(&second_tree, ast.package_decl(&second_tree, 2)).return_type
|
||||
try testing.expect_equal(BuiltinType.bool, binding(&first_resolution, first_return).data.builtin)
|
||||
try testing.expect_equal(BuiltinType.i64, binding(&second_resolution, second_return).data.builtin)
|
||||
try testing.expect_equal(usize(0), diagnostics.count(&first_diagnostics))
|
||||
try testing.expect_equal(usize(0), diagnostics.count(&second_diagnostics))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user