Repository navigation
s2/types: type inference, all generic calls solved (T1) - #21
Merged
Merged
Conversation
…f-host rung T1)
A type is a K.Term (K.Con(name, args)). A callee's [] binders open to fresh K.Vars at each call; the
written type args bind them, then the expected type (check mode first, as s1 vic-m5r.18), then the args
left to right through K.unify. In a generic body the binders are rigid cons. Constructors open their
enum's binders the same way; a match binds each arm's fields with the enum's args; a method is an op
of a capability's protocol or a trait method of {} evidence, with the trait's args from the evidence
type. Every error is a Ty.Clash (Mismatch, Unknown, Arity, NotEnum, NoOp, CannotInfer); every generic
call and constructor records Ty.Inst(line, callee, type args), the input of mono and emit; an instance
with a var left after the whole program is CannotInfer.
tests/s2/types: the prelude and every s2 source (all accepted by s1) type with no clash and over 1000
instances solved; a trait method with binder names unlike the trait's; one program per clash kind.
Mutants: type args dropped, no check mode, arm fields unbound, < typed I64, trait args unbound: each
changes the output.
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.
Self-host rung T1: type inference over the s2 Ast (
s2/types.srs, moduleTy), following s1's rules (vic/c/s2-typing-spec.md).K.Term. A callee's[]binders open to freshK.Vars at each call, then get bound in this order: written type args, then the expected type (check mode first, as s1), then the args left to right throughK.unify. In a generic body the binders are rigid.Ty.Clash(data). Every generic call or constructor recordsTy.Inst(line, callee, type args)for mono and emit; an instance left unsolved isCannotInfer.Oracle: the prelude and every s2 source (all accepted by s1) type with no clash, and over 1000 instances are solved. Extra cases: a trait method whose binder names differ from the trait's, and one program per clash kind.
Five mutants (type args dropped, no check mode, arm fields unbound,
<typed I64, trait args unbound) each change the output; the last one first survived and led to the trait-args case. Local tests/run.sh: 186 ok, 0 FAIL.