I'm writing a toy Pascal compiler in Haskell. I can produce a Type-annotated AST. I've been ignoring function return value assignments:
function foo : integer;
begin
foo := 12
end;
How do I handle those, given that the grammar doesn't distinguish between them and any other regular assignment statement?
Should the AST be modified to specifically highlight a return value assignment?
And how to deal with them in the type checking phase (An environment Symbol table consisting of function signatures and a stack of contexts was enough so far)?
Indentin the function header is the same as one which is the lvalue in an assignment in the function body. IOW, we readers don't know the "syntax of the syntax". Problem gets trickier if you want to coverResult :=Interesting q, +1 - MartynA