Fix parser not being able to parse typed stack functions with another definition as prefix
Clarification and motivation
When we define a let block, and one typed stack function is named, for example, add3
, we aren't then able to use this in a code block. It seems it's because our parser sees the add3
and assumes it's the add
definition, but then it assumes the 3
is a mistake. We have a contract, verbose-typechecking.mtz
, where such a thing happens. We aren't able to use add3
in the code
block, but we can then use it if we remove the definition of add
. Try it.
let {
type num = int;
Three :: int = 3;
add3 :: '[int] -> '[int] = {push int 3; add;};
add3 :: '[int] -> '[int] = {push num Three; add;};
add :: '[int, int] -> '[int] = {sub;};
stkRest :: '[int, ...] -> '[int, ...] = {push int 3; ADD;};
};
parameter unit;
storage unit;
code { DROP;
PUSH nat Three;
drop;
PUSH num Three;
push Three; # remove this line and the next one and use add3, then try to remove the definition of add above
add;
stacktype '[int, ...];
stkRest;
DROP;
UNIT; NIL operation; PAIR; };
This also raises another concern: why are we able to define two let3
s? Which one gets used in code? It makes sense for me to throw an error in this situation.
Acceptance criteria
- We can define
add3
and also other names with existing definitions as prefixes and use them in the code. - An error is shown when we try to declare multiple equal names.
- At least one test is written showing it works as intended.