etk icon indicating copy to clipboard operation
etk copied to clipboard

eas assembles broken contracts when the body is split in multiple includes

Open vyzo opened this issue 3 years ago • 1 comments

I am trying to compose a contract as follows:

%push(body_end - body_begin)
dup1
%push(body_begin)
push1 0x00
codecopy
push1 0x00
return

body_begin:
%include("A.eas")
%include("B.eas")
...
body_end:

Unfortunately the assembly is broken, as eas generates illegal jumps in the body. If I lump all the includes together and do a single file, everything works fine. So this is a bug in the assembly.

vyzo avatar Dec 14 '22 17:12 vyzo

Hey Vyzo, thank you very much for your report. Your problem is mainly because the functionality you are looking for is given by the built-in %import, which inserts the code as if it was typed in the position where the built-in was called.

In the case of using %include, the new code is considered in a completely independent scope, and the labels start counting from zero again, hence your problem.

You can check the documentation for a more detailed explanation.

Thanks again!

P.S: @lightclient I think you can close this issue

gzanitti avatar Oct 09 '23 19:10 gzanitti