fix: canonicalize nested composition references
This commit is contained in:
+13
-12
@@ -16783,7 +16783,7 @@ composed_map :: $(init(ErrorAlias, i32, {
|
||||
}))
|
||||
|
||||
reflects_composed_keys func($E type) bool {
|
||||
keys [4]E := {.shared, .left, .right, .tail}
|
||||
keys [4]E := [.shared, .left, .right, .tail]
|
||||
match typeinfo!(E) {
|
||||
.enum |info|: {
|
||||
if info.fields.len != 4 { return false }
|
||||
@@ -16802,8 +16802,8 @@ reflects_composed_keys func($E type) bool {
|
||||
|
||||
main func() i32 {
|
||||
if !$(reflects_composed_keys(ErrorAlias)) { return 27 }
|
||||
keys [4]ErrorAlias := {.shared, .left, .right, .tail}
|
||||
expected [4]i32 := {10, 20, 30, 40}
|
||||
keys [4]ErrorAlias := [.shared, .left, .right, .tail]
|
||||
expected [4]i32 := [10, 20, 30, 40]
|
||||
for keys |key, index| {
|
||||
if get(&composed_map, key) |value| {
|
||||
if value != expected[index] { return 28 }
|
||||
@@ -16930,6 +16930,8 @@ main func() i32 {
|
||||
enum_field_struct_rejects_payload_sums_and_nominal_unions :: proc(t: ^testing.T) {
|
||||
directory := "/tmp/brolang-test-enum-field-struct-rejections"
|
||||
main_path := "/tmp/brolang-test-enum-field-struct-rejections/main.bro"
|
||||
output := "/tmp/brolang-test-enum-field-struct-rejections-output"
|
||||
defer _ = os.remove(output)
|
||||
_ = os2.remove_all(directory)
|
||||
defer _ = os2.remove_all(directory)
|
||||
testing.expect(t, os.make_directory(directory) == nil)
|
||||
@@ -16941,14 +16943,13 @@ Keys :: alias Payload | Empty`,
|
||||
`Keys :: union { first i32, second i32 }`,
|
||||
}
|
||||
for declaration in declarations {
|
||||
text := fmt.aprintf(`meta :: import "@std/meta"
|
||||
%s
|
||||
text := fmt.aprint("meta :: import \"@std/meta\"\n", declaration, `
|
||||
Flags :: alias meta.EnumFieldStruct(Keys, bool, false)
|
||||
main func() void {
|
||||
flags Flags := {}
|
||||
_ = flags
|
||||
}
|
||||
`, declaration)
|
||||
`)
|
||||
defer delete(text)
|
||||
testing.expect(t, os.write_entire_file(main_path, transmute([]byte)text))
|
||||
sources := source.init_store()
|
||||
@@ -16961,15 +16962,15 @@ main func() void {
|
||||
directory, &sources, &diagnostics, &symbols, project_root_path=".",
|
||||
)
|
||||
defer ast.destroy_module(&module)
|
||||
testing.expect_value(t, len(diagnostics.items), 0)
|
||||
hir_module := checker.check(&module, &diagnostics, &symbols)
|
||||
defer hir.destroy_module(&hir_module)
|
||||
testing.expect(t, loaded)
|
||||
found_rejection := false
|
||||
for diagnostic in diagnostics.items {
|
||||
found_rejection = found_rejection ||
|
||||
strings.contains(diagnostic.message, "EnumFieldStruct key must be an enum")
|
||||
}
|
||||
testing.expect(t, found_rejection)
|
||||
testing.expect(t, len(diagnostics.items) > 0)
|
||||
testing.expect_value(t, compiler_core.compile_package(
|
||||
directory, output, nil, target.DEFAULT, cimport.Options{}, ".",
|
||||
), 1)
|
||||
testing.expect(t, !os.exists(output))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user