Closed ThierryBleau closed 3 years ago
@ThierryBleau What about the following Mesh code:
let x = 0;
x + 2;
let y = "hello";
y ++ " world";
Should it be parsed as:
ELet
expressions with x+2
and y ++ " world"
as their respective scopes)ELet
expression where the scope includes the second ELet
Moreover, defining the let binding AST node as ELet(pattern, expr, expr)
implies that the following mesh code is invalid:
let x = 2;
let y = "hello";
let z = true;
@ThierryBleau What about the following Mesh code:
let x = 0; x + 2; let y = "hello"; y ++ " world";
Should it be parsed as:
- A list of two expressions (i.e.: two
ELet
expressions withx+2
andy ++ " world"
as their respective scopes)- A single
ELet
expression where the scope includes the secondELet
- Parsing error
Should be the second option
Moreover, defining the let binding AST node as
ELet(pattern, expr, expr)
implies that the following mesh code is invalid:let x = 2; let y = "hello"; let z = true;
How so?
As it currently stands, since the parser expects a list of expressions (with let bindings being defined as ELet(pattern, expr)
, the "scope" of a let binding is all the expressions of the list after the let binding.
Is there a way to access the list of subsequent expressions during type inference?
Currently,
ELet
is defined asELet(pattern, expr)
where theexpr
values are bound to variables declared inpattern
. This doesn't define the scope where these variables should be bound. Simple fix: RedefineELet
to have the scope as a second expression ->ELet(pattern, expr, expr)
.