8000 fix: pass `-pkg-sources` of virtual pkg when build & check implement pkg by Young-Flash · Pull Request #798 · moonbitlang/moon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: pass -pkg-sources of virtual pkg when build & check implement pkg #798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025

Conversation

Young-Flash
Copy link
Collaborator

No description provided.

Copy link
Changed tuple structure without type alias

Category
Maintainability
Code Snippet
pub mi_of_virtual_pkg_to_impl: Option<(String, String, String)>
Recommendation
Create a type alias for the tuple structure:

type VirtualPackageInfo = (String, String, String); // (mi_path, pkg_name, pkg_path)
pub mi_of_virtual_pkg_to_impl: Option<VirtualPackageInfo>

Reasoning
The tuple structure (String, String, String) is used in multiple places and its meaning is not immediately clear. A type alias would improve code readability and make the purpose of each field more obvious.

Removed error message check in favor of partial match

Category
Correctness
Code Snippet
let content = get_err_stderr(&err, ["check"]);
assert!(content.contains("[$ROOT/lib1/lib1.mbti:5:1]"));
assert!(content.contains("[$ROOT/lib1/lib1.mbti:3:1]"));
Recommendation
Consider using a more precise error message check or document why partial matching is sufficient:

check(
    get_err_stderr(&err, ["check"]),
    expect![[r#"...[specific error pattern]..."#]]
);

Reasoning
Moving from exact error message matching to partial string matching could make tests more fragile to unrelated changes in error formatting. If the change is intentional, it should be documented why partial matching is preferred.

Redundant string cloning in command generation

Category
Performance
Code Snippet
mi_path.clone(), pkg_name.clone(), pkg_path.clone()
Recommendation
Use references where possible to avoid unnecessary string cloning:

format!("{name}:{path}", name=pkg_name, path=pkg_path)

Reasoning
Multiple clone() calls on strings during command generation could impact performance when building large projects. Using references or format! macro with named parameters could reduce memory allocations.

@Young-Flash Young-Flash merged commit 9e0b1f2 into main May 7, 2025
5 of 13 checks passed
@Young-Flash Young-Flash deleted the pkg-sources-of-virtual-pkg branch May 7, 2025 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0