Skip to content
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

Unresolved const in specs #281

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/main/kotlin/org/move/lang/core/psi/ext/MvElement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ private fun PsiElement.isMslInner(): Boolean {
return CachedValuesManager.getProjectPsiDependentCache(this) {
var element: PsiElement? = it
while (element != null) {
// use items always non-msl, otherwise import resolution doesn't work correctly
if (element is MvUseSpeck) return@getProjectPsiDependentCache false

// module items
if (element is MvModule
|| element is MvFunction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,4 +597,18 @@ module 0x1::m {
}
}
""")

fun `test no unresolved reference for const in spec`() = checkByText("""
module 0x1::features {
const PERMISSIONED_SIGNER: u64 = 84;

}
module 0x1::m {}
spec 0x1::m {
spec fun is_permissioned_signer(): bool {
use 0x1::features::PERMISSIONED_SIGNER;
PERMISSIONED_SIGNER;
}
}
""")
}
15 changes: 15 additions & 0 deletions src/test/kotlin/org/move/lang/resolve/ResolveVariablesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -776,4 +776,19 @@ module 0x1::string_tests {
}
}
""")

fun `test const accessible from spec functions`() = checkByCode("""
module 0x1::features {
const PERMISSIONED_SIGNER: u64 = 84;
//X

}
module 0x1::m {}
spec 0x1::m {
spec fun is_permissioned_signer(): bool {
use 0x1::features::PERMISSIONED_SIGNER;
PERMISSIONED_SIGNER;
//^
}
} """)
}
Loading