Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Fix IF:<{ and IFNOT:<{ empty continuation case #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

akifoq
Copy link

@akifoq akifoq commented Apr 4, 2022

The boolean value should be DROPped in the case the continuation is empty.

To reproduce the bug, you can compare the following fift-assembler programs

"Asm.fif" include
<{ 42 PUSHINT IF:<{ }> }>s runvmcode .s // leaves 42 0

and

"Asm.fif" include
<{ 42 PUSHINT IF:<{ NOP }> }>s runvmcode .s // leaves 0

which obviously should be equivalent.

In some cases FunC compiler indeed produces empty IF:<{ branches, for example consider the following code

int main(int x) {
  int a = 1;
  if (x) { int a = 2; }
  return a;
}

which compiles into

main PROC:<{
  //  x
  1 PUSHINT	//  x a=1
  SWAP	//  a=1 x
  IF:<{	//  a=1
  }>	//  a=1
}>

(the bug was actually met in such situation)

The boolean value should be DROPped in the case the continuation is empty.
Copy link

@tvorogme tvorogme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akifoq thank you for solution, it works for me.

Will patch toncli libs in next version.

@EmelyanenkoK
Copy link
Member

Commits moved to https://github.com/newton-blockchain/ton/tree/akifoq-master
This PR will be open till merging akifoq-master

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

Successfully merging this pull request may close these issues.

3 participants