Fix alias import (#4968)

* Fix alias import

Alias importing was registering the alias id as a decl instead of alias.
This caused issues when hiding and then reimporting the alias.

* Clippy format

Co-authored-by: Hristo Filaretov <h.filaretov@protonmail.com>
This commit is contained in:
Hristo Filaretov 2022-03-25 23:56:40 +01:00 committed by GitHub
parent 66087b01e6
commit 8a9cc33aac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 2 deletions

View File

@ -71,5 +71,5 @@ cargo build
- To view verbose logs when developing, enable the `trace` log level. - To view verbose logs when developing, enable the `trace` log level.
```shell ```shell
cargo build --release --features=extra && cargo run --release --features=extra -- --loglevel trace cargo build --release --features=extra && cargo run --release --features=extra -- --log-level trace
``` ```

View File

@ -779,7 +779,7 @@ impl<'a> StateWorkingSet<'a> {
for (name, alias_id) in aliases { for (name, alias_id) in aliases {
scope_frame.aliases.insert(name, alias_id); scope_frame.aliases.insert(name, alias_id);
scope_frame.visibility.use_decl_id(&alias_id); scope_frame.visibility.use_alias_id(&alias_id);
} }
} }

View File

@ -296,6 +296,70 @@ fn hides_def_import_6() -> TestResult {
) )
} }
#[test]
fn hides_def_import_then_reimports() -> TestResult {
run_test(
r#"module spam { export def foo [] { "foo" } }; use spam foo; hide foo; use spam foo; foo"#,
"foo",
)
}
#[test]
fn hides_alias_import_1() -> TestResult {
fail_test(
r#"module spam { export alias foo = "foo" }; use spam; hide spam foo; spam foo"#,
"", // we just care if it errors
)
}
#[test]
fn hides_alias_import_2() -> TestResult {
fail_test(
r#"module spam { export alias foo = "foo" }; use spam; hide spam; spam foo"#,
"", // we just care if it errors
)
}
#[test]
fn hides_alias_import_3() -> TestResult {
fail_test(
r#"module spam { export alias foo = "foo" }; use spam; hide spam [foo]; spam foo"#,
"", // we just care if it errors
)
}
#[test]
fn hides_alias_import_4() -> TestResult {
fail_test(
r#"module spam { export alias foo = "foo" }; use spam foo; hide foo; foo"#,
"", // we just care if it errors
)
}
#[test]
fn hides_alias_import_5() -> TestResult {
fail_test(
r#"module spam { export alias foo = "foo" }; use spam *; hide foo; foo"#,
"", // we just care if it errors
)
}
#[test]
fn hides_alias_import_6() -> TestResult {
fail_test(
r#"module spam { export alias foo = "foo" }; use spam *; hide spam *; foo"#,
"", // we just care if it errors
)
}
#[test]
fn hides_alias_import_then_reimports() -> TestResult {
run_test(
r#"module spam { export alias foo = "foo" }; use spam foo; hide foo; use spam foo; foo"#,
"foo",
)
}
#[test] #[test]
fn hides_env_import_1() -> TestResult { fn hides_env_import_1() -> TestResult {
fail_test( fail_test(