Invalid Token for some {but not all}Scripts & modules

I got some error that i don’t understand by using the Tutorial Script/Module of the documentation.

Some code compile perfectly but the basic i always got an invalid token response.

The script :

use 0x0.LBR;
use 0x0.Libra;
use 0x0.LibraAccount;
fun main(payee: address, amount: u64) {
  let coin = LibraAccount::withdraw_from_sender<LBR::T>(amount);
  LibraAccount::deposit(payee, coin)
}

The invalid token error

>> Compiling program
    Finished dev [unoptimized + debuginfo] target(s) in 0.36s
     Running `target/debug/compiler -l /tmp/a3019ac311def005aa2e52fc4b5eccab.mvir`
error: Parser Error

   ┌── /tmp/a3019ac311def005aa2e52fc4b5eccab.mvir:1:1 ───
   │
 1 │ use 0x0.LBR;
   │ ^^^ Invalid Token
   │

thread 'main' panicked at 'Unable to parse module: ParserError: Invalid Token', language/compiler/src/main.rs:110:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
EOF while parsing a value at line 1 column 0

any idea what i am missing ? some module works… but since a week i never handle to compile a script.

Thanks

edit : if i replace the use by import … the fun become the invalid token

and even Module and script inside this page never work : https://developers.libra.org/docs/run-move-locally

for the My_Module.mvir this is the error :

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Dependency not provided for 00000000000000000000000000000000.LibraCoin', 
/root/libra/language/compiler/src/util.rs:22:clock5:

This is fallout from PR #3425 that changes to use the Move source language instead of Move IR. We’ll need to get that document updated. There are basically 3 things to change:

  • Rewrite the Move code in the source language instead of Move IR. (We’ll update the examples.)
  • Remove the “script” and “module” arguments to the “compile” command
  • Add new arguments to the “compile” command that give the file paths to the Move source dependencies. Most of the time this is just the file path to the Move standard library (i.e., “language/stdlib/modules” in the Libra sources), but if you have a custom module (e.g., “MyModule” in the examples) then you also need to specify the source file for that module when compiling a script that uses it.
2 Likes

For this specific problem, the right fix is . -> ::

use 0x0::LBR; use 0x0::Libra; use 0x0::LibraAccount;

In Move source code (.move files), :: is always the separator between account addresses and module names (e.g., 0x0::LBR), module names and type names (e.g., LBR::T), and module names and function names (e.g., LibraAccount::deposit). The . syntax is only used for field accesses (e.g., y = &x.f).

1 Like

ok i got it , thank you.

The docs should really be updated :smiley:

hum , i thought i get it … but not.

How to Rewrite the Move code in the source language instead of Move IR ?

You can look at the pull request I mentioned earlier. It includes a copy of the example code translated into Move source language.

We have updated the document now. Thanks for pointing out this problem!

1 Like

that’s great , thanks, this MOVe langage is challenging , i like it.