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
The typing logic for SId is split between several functions: tcId, tcIdVariable, tcLetAnnotation, tcUserConstant, lookupFun, lookupVarDef, lookupTypeDef, tcIdBuiltinSymbol, tcIdImportUnitRef. Whats worse, there are 2 redundant styles of checking types:
a) Using an explicit stack of scopes (see lookupVarDef for an example)
b) A messy bunch of ifs all over the place. (see tcId for an example of this)
This logic is ugly, over-complicated and probably has a lot of buggy edge-cases with shadowing.
I think it would be cleaner if we had a single way to type-check SIds, just using a single explicit stack of scopes. In that case we would:
Unify lookupVarDef, lookupFun, lookupTypeDef and tcLetAnnotationId into a single lookupDef function.
Replace all the tc* functions with a single tcId function whose body will look almost exactly like the body of tcIdVariable
We will add a new BuiltinsScope type for all the builtins (its not clear yet exactly where that will go).
For every 2 types of DefSites we will need a test to determine how they get shadowed. For example for builtins and variables, we will need to see if a local variable called msg shadows the msg builtin. Similarly for variables and functions, we will need a test checking their precedence. And so on and so forth.
In practice, its probably better to first start with the tests in (4) and then begin implementing the code changes.
The text was updated successfully, but these errors were encountered:
The typing logic for
SId
is split between several functions:tcId
,tcIdVariable
,tcLetAnnotation
,tcUserConstant
,lookupFun
,lookupVarDef
,lookupTypeDef
,tcIdBuiltinSymbol
,tcIdImportUnitRef
. Whats worse, there are 2 redundant styles of checking types:a) Using an explicit stack of scopes (see
lookupVarDef
for an example)b) A messy bunch of ifs all over the place. (see
tcId
for an example of this)This logic is ugly, over-complicated and probably has a lot of buggy edge-cases with shadowing.
I think it would be cleaner if we had a single way to type-check
SId
s, just using a single explicit stack of scopes. In that case we would:lookupVarDef
,lookupFun
,lookupTypeDef
andtcLetAnnotationId
into a singlelookupDef
function.tc*
functions with a singletcId
function whose body will look almost exactly like the body oftcIdVariable
BuiltinsScope
type for all the builtins (its not clear yet exactly where that will go).DefSites
we will need a test to determine how they get shadowed. For example for builtins and variables, we will need to see if a local variable calledmsg
shadows themsg
builtin. Similarly for variables and functions, we will need a test checking their precedence. And so on and so forth.In practice, its probably better to first start with the tests in (4) and then begin implementing the code changes.
The text was updated successfully, but these errors were encountered: