MystenLabs / sui

Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by the Move programming language
https://sui.io
Apache License 2.0
6.2k stars 11.2k forks source link

There are some error in the generation of diagnostic message in move-compiler #18210

Open hapeeeeee opened 5 months ago

hapeeeeee commented 5 months ago

We are developing sui-move-analyzer to be compatible with the 2024.beta version of the Sui Move language, based on the version: (git = "https://github.com/MystenLabs/sui.git", rev = "6e1cf7a1a9971fedd8b7830e586029d6c2cf801a").

We have found that the interface for generating diagnostics (compiler.run::) seems to have issues. The diagnostic information at this level appears incorrect. When encountering types provided by Sui itself, an "unbound type" message appears. For example, ID and TxContext.

image image

The diagnostic information only does not appear if the Sui types are explicitly imported using the use statement, such as use sui::object::ID, or if sui::object::ID and sui::tx_context::TxContext are specified when using these types. image

awelc commented 5 months ago

I suspect that this has something to do with implicit imports of the commonly used modules (explicit imports incorrectly shadowing implicit ones?). @tnowacki, is this the intended behavior?

tnowacki commented 4 months ago

Have you set the flavor to Sui? This is done in the package config.

As a side note, I would probably also advise against invoking the compiler directly, and instead using the package system with the custom compiler driver, compile_with_driver

hapeeeeee commented 4 months ago

Have you set the flavor to Sui? This is done in the package config.

As a side note, I would probably also advise against invoking the compiler directly, and instead using the package system with the custom compiler driver, compile_with_driver

I tried introducing Sui in the dependencies of sui-move-analyzer, but the issue still persists. On the other hand, the current diagnostic information generation is already based on the compile_with_driver function, as shown in the picture below.

image

cgswords commented 4 months ago

@hapeeeeee

  1. Is Sui listed as a dependency in your Move.toml?
  2. Are you explicitly setting the package to sui mode (via build_config.default_flavor = Some(Flavor::Sui))?
stefan-mysten commented 3 months ago

@hapeeeeee have you managed to get this working? If so, let's close this issue. If not, feel free to add more details so that the team can help you.