반환값이나 로컬변수(반환값 포함)가 너무(?) 많으면 생기는 오류입니다
function stackTooDeep() public pure returns(string memory, uint, int, int, int, int, int, int, int, int, int, int, int){
return ("a",1,2,3,4,5,6,7,8,9,10,11,12);
}
이처럼 배꼽이 더 큰 함수를 만든다고 쳤을 때 아래와 같은 오류가 뜨죠
CompilerError: Stack too deep when compiling inline assembly: Variable value0 is 1 slot(s) too deep inside the stack.
https://medium.com/1milliondevs/compilererror-stack-too-deep-try-removing-local-variables-solved-a6bcecc16231
위 링크의 닉 멋지좌의 설명에 따르면 모든 반환값들을 구조체로 묶어서 반환하면 된다고 합니다
struct Trashes{
string a;
uint b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;
int k;
int l;
int m;
}
function stackTooDeep() public pure returns(Trashes memory){
Trashes memory trashes = Trashes("a",1,2,3,4,5,6,7,8,9,10,11,12);
return trashes;
}
요런식으로 하면 오류없이 잘됩니다!
쓰레기는 묶어서 배출합시다