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

Compilation error when less than operator is attached with the variable on the left. #17823

Closed
purusang opened this issue May 20, 2024 · 2 comments
Assignees
Labels

Comments

@purusang
Copy link

purusang commented May 20, 2024

Steps to Reproduce Issue

With the following code you may encounter an error on sui move build. The best way to reproduce is to use '<' sign attached with the variable on its left inside if or while.
I have tested it multiple times and got the same error.

My code snippet:

        while(sub_len>0) {    // 0 or 1?
            hash_value = poseidon::poseidon_bn254(&vector[hash_value, hash_value]);
            let mut j = sub_len/2;
            while(j< sub_len){
            //     // let mut e: u256 = vector::borrow_mut<u256>( tree_array, j);
            //     j = j+ 1;
            };
            
        };

Expected Result

Compilation should have been successful.

Actual Result

error[E01002]: unexpected token
┌─ ./sources/merkle_tree.move:47:29

47 │ while(j< sub_len){
│ ^
│ │
│ Unexpected ')'
│ Expected ',' or '>'

error[E01002]: unexpected token
┌─ ./sources/merkle_tree.move:47:30

47 │ while(j< sub_len){
│ - ^ Expected '>'
│ │
│ To match this '<'

error[E01002]: unexpected token
┌─ ./sources/merkle_tree.move:50:14

50 │ };
│ ^
│ │
│ Unexpected ';'
│ Expected ')'

error[E01002]: unexpected token
┌─ ./sources/merkle_tree.move:52:10

52 │ };
│ ^
│ │
│ Unexpected ';'
│ Expected a module member: 'spec', 'use', 'friend', 'const', 'fun', 'struct', or 'enum'

Failed to build Move modules: Compilation error.

System Information

  • OS: macos
  • Compiler: sui-move 1.23.1-4dbcf811ab
@stefan-mysten
Copy link
Contributor

stefan-mysten commented May 21, 2024

Thanks for reporting this @purusang! This is a known issue and it has to do with lexing and parsing the code. The team is aware of this and added it to the backlog.

In the meantime, please use spaces before and after the < character to avoid this parsing error.

 while( j < sub_len ){ 

@purusang
Copy link
Author

Thank you too @stefan-mysten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants