-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strict typechecking mode #2077
Strict typechecking mode #2077
Conversation
|
Branch | 2077/merge |
Testbed | ubuntu-latest |
⚠️ WARNING: The following Measure does not have a Threshold. Without a Threshold, no Alerts will ever be generated!Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholds
CLI flag.
Click to view all benchmark results
Benchmark | Latency | nanoseconds (ns) |
---|---|---|
fibonacci 10 | 📈 view plot | 494,100.00 |
foldl arrays 50 | 📈 view plot | 1,771,100.00 |
foldl arrays 500 | 📈 view plot | 6,748,500.00 |
foldr strings 50 | 📈 view plot | 7,256,500.00 |
foldr strings 500 | 📈 view plot | 63,521,000.00 |
generate normal 250 | 📈 view plot | 46,735,000.00 |
generate normal 50 | 📈 view plot | 2,101,700.00 |
generate normal unchecked 1000 | 📈 view plot | 3,247,200.00 |
generate normal unchecked 200 | 📈 view plot | 749,480.00 |
pidigits 100 | 📈 view plot | 3,230,800.00 |
pipe normal 20 | 📈 view plot | 1,490,300.00 |
pipe normal 200 | 📈 view plot | 10,218,000.00 |
product 30 | 📈 view plot | 831,740.00 |
scalar 10 | 📈 view plot | 1,516,400.00 |
sum 30 | 📈 view plot | 830,670.00 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed while testing that despite the "strict" in the name, it's sometimes more permissive than non-strict mode (because of type inference; see the added tests). Maybe "strict" mode should run both kinds of typechecking so it's actually strictly stricter?
I think it's fine as it is; it's the expected semantics (as you say, it behaves is if we put : _
every where at the top of each file), and while it's more permissive, it's not accepting dubious programs. I would say that it's smarter rather than just more permissive.
Regarding tests, maybe we should add a test that imports are also properly strictly typechecked.
core/src/typecheck/mod.rs
Outdated
@@ -1382,8 +1382,10 @@ pub fn type_check( | |||
t: &RichTerm, | |||
initial_ctxt: Context, | |||
resolver: &impl ImportResolver, | |||
strict: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: there is an enum typecheck::pattern::TypecheckMode = { Walk, Enforce }
. Maybe it would be better to use that instead of a boolean (boolean blindness and all that) ? In that case maybe hoist it up in the typecheck
module, because it's not for patterns only anymore.
Ok but now maybe I see your point: it might be surprising that some files require |
I was mainly thinking from the point of view of someone wanting to run extra checks in CI. There, you don't really care if |
Hmm, indeed. By the way, should we make And if it starts to be too slow, we can easily make it so that the typechecker just ignores any expression with a type or a contract annotation on the second run (some kind of Another solution would be to rerun the typechecker in strict mode upon failure in normal execution: if the program is typeable with a bit more effort, then we accept it. But I'm not sure it's such a good idea: if people start to rely on this behavior, then the default path would waste work in the first attempt at each execution. |
Wait, we can't do that, because that won't catch your example. Maybe the converse is fine though: first run the normal pass, and for the strict pass, only reprocess what was untyped before? Since inference is more powerful, it seems like if a typed block passes the normal phase, then it would necessarily pass the strict one. Would have to think a bit harder to make sure. |
This adds a
--strict-typechecking
flag that starts the typechecker in "checking" mode, equivalent to wrapping each file in(...) : _
.A couple of points I was unsure of:
Fixes #2049