tact-lang / tact-vscode

Tact VS Code plugin
Apache License 2.0
14 stars 7 forks source link

Code disappeared after formatting #8

Closed WaterSo0910 closed 9 months ago

WaterSo0910 commented 9 months ago

I just use this extension and after saving on format, my code just disappear.

And I found that if there exists throw in the tact file, then it will trigger this abnormal behaviour.

WaterSo0910 commented 9 months ago

[Update] I found that there exists other things can trigger this more than throw 😭

logvik commented 9 months ago

Can you share some code that I can test? Just formatting is not fully tested feature...

WaterSo0910 commented 9 months ago

Tks for reply. I'd like to highlight the specific scenarios:

  1. Usage of throw
    
    import "./msg_types";

contract Messenger { owner: Address; // Router Address sourceAddress: Address; init(owner: Address){ self.owner = owner; }

receive(msg: BuildMessenger){
    if (msg.sourceAddress != self.sourceAddress) {
        throw(113);
    }
}

}


2. Usage of `with` without a following word like Ownable

import "./msg_types"; import "@stdlib/ownable";

contract Messenger with { owner: Address; // Router Address sourceAddress: Address; init(owner: Address){ self.owner = owner; }

receive(msg: BuildMessenger){
    if (msg.sourceAddress != self.sourceAddress) {}
}

}


Additionally, perhaps there are other scenarios that haven't been discovered yet

I'd appreciate it if you could look into this and advise on a potential fix or workaround. Thank you for your support and dedication to this awesome project. 👍 
logvik commented 9 months ago
  1. issue with throw fixed on 1.0.4
  2. the with without a following word like Ownable is not a valid case. The parser doesn't expect this, because it is the same as write if and didn't continue the input. I don't know why the tact-parser doesn't warn this issue, but I decided that for such cases the code will be remain the same after the formating. And only for a valid code the formatting feature will be applied.
WaterSo0910 commented 9 months ago

LGTM. Thanks a lot for contributing this neccesary dev tool :+1:

logvik commented 9 months ago

you are welcome, thank you too!