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
This was implemented in the initial release but relied on mutating Type during checking which caused problems in conditional branches and the such. This issues is a second attempt that stores "requests" that are applied at the boundary.
A aim of Ezno is to work without writing type annotations. Variables don't need them because of the value system, return types are based on the body. The final piece is the unknown-ness of inputs to functions.
This can be in several places:
Explicit parameter
functionfunc1(a){returna.x// The constraint of `a` should be inferred as `{ x: any }`}
Non restricted variable
leta=4;functionfunc2(){returnMath.sin(a)// The constraint of closed over references `a` should be inferred as number (with strict casts at least)}
Cycles (recursion)
interfaceNode{parent: Node|null,x:
}functiondepth(obj: Node){if(obj.parent){// `depth` hasn't been checked yet. A restriction should be madereturndepth(obj.parent)+1}else{return0}}
A aim of Ezno is to work without writing type annotations. Variables don't need them because of the value system, return types are based on the body. The final piece is the unknown-ness of inputs to functions.
This can be in several places:
Explicit parameter
Non restricted variable
Cycles (recursion)
See #29
Others
any
asunknown
To better support existing codebases
any
should be treated asunknown
. No annotation should be treated asunknown
Combining restrictions
When two restrictions are made they are combined using
&
param1
is now restricted toX & Y
.this might create impossible types (string & number), which is fine but a warning should be raised
Places where constraint inference is done
x
has a unknown restriction andx <: number
is evaluated, thenx
's restriction becomesnumber
I had up to here existing implemented, the hard part is now:
Nesting
This needs to place a inference condition on a inference restriction 😅
The non-local
unknown
issueIf
unknown
is found on a fixed restriction, then a nested dynamic restriction might have to be on a fixed restriction.extended from https://github.com/kaleidawave/ezno/blob/main/checker/docs/inference.md
It is still in progress the best way to tackle this, interested if people have real world parameter inference examples they want supported:
The text was updated successfully, but these errors were encountered: