Skip to content

Commit 87be6b8

Browse files
authored
add UDT to list of terms when processing reexport (#2154)
Closes #2146 I also found another unrelated bug while working on this, which I filed here: #2153
1 parent e24e690 commit 87be6b8

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

compiler/qsc_frontend/src/compile/tests/multiple_packages.rs

+41
Original file line numberDiff line numberDiff line change
@@ -602,3 +602,44 @@ fn callable_reexport() {
602602
),
603603
]);
604604
}
605+
606+
#[test]
607+
fn old_syntax_udt_reexported() {
608+
multiple_package_multiple_source_check(
609+
vec![
610+
(
611+
"A",
612+
vec![
613+
(
614+
"FileOne",
615+
"
616+
struct Foo { content: Bool, otherContent: Bool }
617+
newtype Bar = ( content: Bool, otherContent: Bool );
618+
",
619+
),
620+
("FileTwo", "export FileOne.Foo as Bar, FileOne.Bar as Baz;"),
621+
],
622+
),
623+
(
624+
"B",
625+
vec![(
626+
"FileThree",
627+
"export A.FileTwo.Bar as Baz, A.FileTwo.Baz as Quux;",
628+
)],
629+
),
630+
(
631+
"C",
632+
vec![(
633+
"FileFour",
634+
"@EntryPoint()
635+
operation Main() : Unit {
636+
// use old UDT syntax with both a struct and a newtype
637+
let x = B.FileThree.Baz(true, true);
638+
let x = B.FileThree.Quux(true, true);
639+
}",
640+
)],
641+
),
642+
],
643+
Some(&expect!["[]"]),
644+
);
645+
}

compiler/qsc_frontend/src/resolve.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,10 @@ impl GlobalTable {
16801680
global.name.clone(),
16811681
Res::Item(item_id, ItemStatus::Available),
16821682
);
1683+
self.scope.terms.get_mut_or_default(namespace).insert(
1684+
global.name.clone(),
1685+
Res::Item(item_id, ItemStatus::Available),
1686+
);
16831687
}
16841688
hir::ItemKind::Export(_, _) => {
16851689
unreachable!("find_item will never return an Export")

0 commit comments

Comments
 (0)