Repository navigation
Report a capability used as a value in Flow terms, not as a clang error (#561) - #569
Merged
Merged
Conversation
…or (#561) A capability is a handler, not a value. Naming one at a call site produced "Undefined variable 'UnitCounter'" under strict checking, which does not mention capabilities at all, and under --lenient it reached the backend and emitted C referencing a symbol nothing defines: dyn.c:159:43: error: use of undeclared identifier 'UnitCounter' Both now report: Capability 'UnitCounter' is not a value and cannot be passed as an argument. Install it for the call instead: handle <Effect> with UnitCounter { ... } This needed a fatal_errors channel on TypeCheckResult that --lenient does not downgrade. --lenient means "compile anyway", which should not extend to emitting C that cannot build; the author gets a message about their own source instead of a clang error naming an identifier they never wrote. Ordinary undefined names are untouched and still warn under --lenient. The declaration form is unaffected. A function may still declare a `capability EffectName` parameter and call operations on it, which tests/unit/test_coverage_known_bugs.py covers; there is simply no way to produce the value to pass. The note in docs/effects-showcase.md said the parameter style was "rejected by the type checker", which was never the case, and described the lenient behaviour this commit changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #561.
The defect
A capability is a handler, not a value. Naming one at a call site was reported badly in both modes.
Strict checking said nothing about capabilities:
--lenientgot further and emitted C referencing a symbol nothing defines:This is the issue's option 1: reject it in the front end with a message naming the construct.
After
Both modes now report:
and exit 1.
The one design decision
Keeping this fatal under
--lenientneeded afatal_errorslist onTypeCheckResultthat lenient mode does not downgrade.--lenientmeans "compile anyway", which should not extend to emitting C that cannot build: the author gets a message about their own source instead of a clang error naming an identifier they never wrote. Ordinary undefined names are untouched and still warn under--lenient.What is not changed
The declaration form still works. A function may declare a
capability EffectNameparameter and call operations on it.tests/unit/test_coverage_known_bugs.py::test_capability_parameter_method_call_type_checks_by_effect_signaturecovers that and still passes — an earlier attempt of mine rejected the declaration and that test correctly caught it. The gap is purely that there is no way to produce the value to pass, which is the issue's option 2 and remains open.Docs
docs/effects-showcase.mdsaid the parameter style was "rejected by the type checker", which was never true, and then described the lenient behaviour this PR changes. Rewritten to say what actually holds.Verification
pytest tests/./flow test --tier2 --strictruff check srcFive new tests in
tests/unit/test_capability_not_a_value.pycover the message, that it points athandle, that lenient keeps it fatal, that an ordinary undefined name is unaffected, and that capability parameters still type check.