solang icon indicating copy to clipboard operation
solang copied to clipboard

Infinite recursion in emit for recursive function arguments

Open xermicus opened this issue 2 years ago • 1 comments

Describe the bug The following snip causes an infinite recursion in emit:

struct S {
    int256 f1;
    S[] f2;
}

// FIXME (stack overrun in emit):
function foo(S memory s) pure {}

contract Foo {
	function bar() public {
		S memory s = S({ f1: 1, f2: new S[](0) });
		foo(s);
	}
 }

To Reproduce

Expected behavior This is allowed in solc too, it should compile to a valid contract

xermicus avatar Mar 08 '23 17:03 xermicus

@LucasSte found another broken example

contract Test {
	struct S {
		int foo;
		S[] s;
	}

	function test(int foo) public returns (S) {
        S ss = S(foo, new S[](2));
        return ss;
    }
}

xermicus avatar Mar 08 '23 22:03 xermicus