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

fix: some yul commands cause compile error (iszero, eq, etc) #2

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

Conversation

Taewa
Copy link

@Taewa Taewa commented Feb 27, 2023

forge test throw an error due to the some of yul functions such as iszero or eq, etc.

I will leave here an example code in order to reproduce the issue.

// yul contract
object "CompileTest" {
    code {
        datacopy(0, dataoffset("Runtime"), datasize("Runtime"))
        return(0, datasize("Runtime"))
    }

    object "Runtime" {
        code {
            function lte(a, b) -> r {
                r := iszero(gt(a, b))
            }

            function returnUint(v) {
                mstore(0, v)
                return(0, 0x20)
            }
        }
    }
}

and test code

// CompileTest.t.sol
pragma solidity 0.8.15;

import "forge-std/Test.sol";
import "./lib/YulDeployer.sol"; 

interface CompileTest {}

contract CompileTestTest is Test {
    YulDeployer yulDeployer = new YulDeployer();

    CompileTest compileTestContract;

    function setUp() public {
        compileTestContract = CompileTest(yulDeployer.deployContract("CompileTest"));
    }

    function testExample() public {
        // Don't do anything
    }
}

the error:

stderr err="Error: Function "iszero" not found.
  --> yul/CompileTest.yul:10:22:
   |
10 |                 r := iszero(gt(a, b))
   |                      ^^^^^^

Error: Variable count for assignment to "r" does not match number of values (1 vs. 0)
  --> yul/CompileTest.yul:10:17:
   |
10 |                 r := iszero(gt(a, b))
   |                 ^^^^^^^^^^^^^^^^^^^^^

Error: 
u{1b}[31mInvalid datau{1b}[0m
"
2023-02-25T06:33:11.819759Z ERROR forge::runner: setUp failed reason="EvmError: Revert" contract=0x7fa9385be102ac3eac297483dd6233d62b3e1496

@yellowBirdy
Copy link

Would be good to merge it , had the same issue

@Taewa
Copy link
Author

Taewa commented Jul 24, 2023

Would be good to merge it , had the same issue

In order to merge it, I need maintainer's approval, right?

@CodeForcer @flyq

Copy link
Contributor

@flyq flyq left a comment

Choose a reason for hiding this comment

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

  --yul                Switch to Yul mode, ignoring all options except
                       --machine, --yul-dialect, --optimize and
                       --yul-optimizations and assumes input is Yul.
  --strict-assembly    Switch to strict assembly mode, ignoring all options
                       except --machine, --yul-dialect, --optimize and
                       --yul-optimizations and assumes input is strict
                       assembly.

is the error caused by iszero is a strict assembly, not Yul?

@Taewa
Copy link
Author

Taewa commented Jul 24, 2023

  --yul                Switch to Yul mode, ignoring all options except
                       --machine, --yul-dialect, --optimize and
                       --yul-optimizations and assumes input is Yul.
  --strict-assembly    Switch to strict assembly mode, ignoring all options
                       except --machine, --yul-dialect, --optimize and
                       --yul-optimizations and assumes input is strict
                       assembly.

is the error caused by iszero is a strict assembly, not Yul?

Yes I experienced the error I mentioned above with --yul. I fixes the error when I use --strict-assembly.

@Taewa
Copy link
Author

Taewa commented Jul 28, 2023

@flyq thanks for the approval. Do I have right to merge or someone else should merge it?

@pawurb pawurb mentioned this pull request Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants