Comments (4)
Do you know if there are any scoping rules specific to this naming? Like, MODULE_NAME.spec.move
having exclusive access to all items in the MODULE_NAME.move
file, something like that? Maybe there are some docs?
from intellij-move.
I've added support for those files in 1.18.0, I'm going to release a new version at the beginning of the next week.
Spec modules scoping is really weird, basically, this code is valid
module 0x1::basket {
fun main() {
let _a = string::utf8(b"hello");
}
}
spec 0x1::basket {
use std::string;
}
and those spec
modules can be anywhere in the package.
from intellij-move.
I've added support for those files in 1.18.0, I'm going to release a new version at the beginning of the next week.
Spec modules scoping is really weird, basically, this code is valid
module 0x1::basket { fun main() { let _a = string::utf8(b"hello"); } } spec 0x1::basket { use std::string; }and those
spec
modules can be anywhere in the package.
The scoping was designed like so that if something is only used in the specification, it wouldn't be included in the final dependencies of the module bytecode.
Thanks for making this happen! I guess you are using the Move compilers expansion phase to also deal with spec name resolution? After expansion, the Move compiler and the Spec compiler go very different ways.
from intellij-move.
The scoping was designed like so that if something is only used in the specification, it wouldn't be included in the final dependencies of the module bytecode.
Yes, this is what I assumed, I expected the "spec" scope to be nested to the "main" scope, like
module 0x1::main {
spec 0x1::main {
use 0x1::string; // isn't visible outside the scope
}
}
but implicitly. And schema
, spec fun
imports will be special cased to be importable from the module itself, to be able to use
use 0x1::main::MySchema;
I just don't understand why imports inside the spec code leak into the main code. From the point of the compiler implementation, you can't just use local information to resolve names in the module anymore (for the non-spec code), you need to go through the whole package to try to find spec MODULE_NAME {}
blocks and check for the imports there. Maybe it's a bug?
Thanks for making this happen! I guess you are using the Move compilers expansion phase to also deal with spec name resolution? After expansion, the Move compiler and the Spec compiler go very different ways.
If you mean the Move compiler itself:
no, I don't use it, Intellij-Move basically reimplements the compiler in Kotlin. I have a scoping rule, which splits spec items and non-spec items into separate groups.
from intellij-move.
Related Issues (20)
- Feature request: Display structure name and contents
- [Feature Request] Allow names to be sorted within their types in Structure View
- Support _ in numeric values HOT 4
- Support the new IDE version 2023.2 HOT 1
- BUG: Structure view isn't sorted at all HOT 5
- Sort elements in the Structure View by the item type (structs / functions / consts)
- Create consts node in structure view
- "Module is declared with a different address `aptos_framework`" but move compiler doesn't report this HOT 2
- Plugin flags error on parenthesis, but compiler doesn't
- Doesn't show up in `Rust Rover` plugin marketplace HOT 7
- Incompatible with CLion Build 233 HOT 2
- Can't normally integrate sui plugin into my intelliji idea on win11 env HOT 4
- v1.33.0.233 Goto definitions dont work. No intellisense for imports too HOT 6
- Linter that can be used in CI HOT 5
- Incompatible with Build 241 HOT 3
- Support Move 2024 HOT 1
- [Bug] Function calls and dependencies are no longer clickable for local dependencies HOT 1
- [Feature Request] Show warning when there's a cast without ()
- [Minor improvement] Make error messages regarding missing type declaration for constants clearer
- [bug] Inline functions should not have acquires HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intellij-move.