You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the compilation environment (net.hydromatic.morel.compile.Environment) the key for values was previously a String (the name of the variable) but is now a Core.NamedPat (the name plus an ordinal). This accommodates duplicate names, which can occur by certain kinds of inlining.
For example, if you inline
from e in (from e in emps yield {e.deptno, e.ename})
where e.deptno = 30
you get
from e in emps
yield {e.deptno, e.name}
yield {e_1 = e}
where e_1.deptno = 30
(where e_1 is a variable whose name is "e" and ordinal is 1 and e is a variable whose name is "e" and ordinal is 0). The variables shadow each other before inlining but they need to coexist after inlining.
As part of this change we add class RefChecker, to check that variables referenced are in scope. If, in the above, we changed where e_1.deptno = 30 to where e.deptno = 30, RefChecker would notice that the output bindings of the yield {e_1 = e} step contained e_1 and not e, and. therefore where e.deptno = 30 is invalid.
And we fix EnvShuttle and EnvVisitor for problems found by RefChecker.
The text was updated successfully, but these errors were encountered:
…, not just name, to accommodate variable copies caused by inlining
Add class RefChecker to detect bad references in FromBuilder.
In EnvVisitor, improve the environment passed to Group;
in EnvVisitor and EnvShuttle, RecValDecl adds to the
environment in which the expression body is processed.
Generate fewer new variables when copying a Yield step.
When copying a Yield step like '{a = exp1, b = exp2}', inherit
bindings from the previous version of the step so that the
'a' and 'b' varibles have the same ordinal, and will match
the variables needed by the next step.
We can remove a trivial Yield, but 'yield {e=e}' isn't
trivial if the output IdPat has a different ordinal than the
input IdPat.
Fixeshydromatic#179
…, not just name, to accommodate variable copies caused by inlining
Add class RefChecker to detect bad references in FromBuilder.
In EnvVisitor, improve the environment passed to Group;
in EnvVisitor and EnvShuttle, RecValDecl adds to the
environment in which the expression body is processed.
Generate fewer new variables when copying a Yield step.
When copying a Yield step like '{a = exp1, b = exp2}', inherit
bindings from the previous version of the step so that the
'a' and 'b' varibles have the same ordinal, and will match
the variables needed by the next step.
We can remove a trivial Yield, but 'yield {e=e}' isn't
trivial if the output IdPat has a different ordinal than the
input IdPat.
Fixeshydromatic#179
In the compilation environment (
net.hydromatic.morel.compile.Environment
) the key for values was previously aString
(the name of the variable) but is now aCore.NamedPat
(the name plus an ordinal). This accommodates duplicate names, which can occur by certain kinds of inlining.For example, if you inline
you get
(where
e_1
is a variable whose name is "e" and ordinal is 1 ande
is a variable whose name is "e" and ordinal is 0). The variables shadow each other before inlining but they need to coexist after inlining.As part of this change we add
class RefChecker
, to check that variables referenced are in scope. If, in the above, we changedwhere e_1.deptno = 30
towhere e.deptno = 30
,RefChecker
would notice that the output bindings of theyield {e_1 = e}
step containede_1
and note
, and. thereforewhere e.deptno = 30
is invalid.And we fix
EnvShuttle
andEnvVisitor
for problems found byRefChecker
.The text was updated successfully, but these errors were encountered: