verona-type-inference
Skill3.7k starsChanged 3 months agoMITView on GitHub
Verona compiler type inference model — bidirectional refinement, per-function inference, lambda/context propagation, algebraic and structural typing, generics, and debugging. Use when changing or debugging `vc/passes/infer.cc` or investigating type inference failures.
Trending
Quiet this year.about the whole repository
Who's talking about microsoft/verona
- A Hacker News story“Microsoft Project Verona: Research programming language for concurrent ownership”Hacker News · Jan 17, 2020 · 142 points
- A Hacker News story“Project Verona FAQ”Hacker News · Feb 10, 2020 · 29 points
- A Hacker News story“Project Verona: Research programming language for concurrent ownership”Hacker News · Jan 16, 2020 · 7 points
- A Hacker News story“Microsoft/Verona”Hacker News · Jan 18, 2020 · 3 points
- A Hacker News story“Concurrent Ownership in Verona”Hacker News · Dec 14, 2022 · 2 points
The biggest 5 of 18 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 18
Talked about on GitHub and Hacker News (18 times).
On GitHub · 12
- Dec 31, 2023Check ideas from Verona language for concurrency — lambdaclass/concrete0 reactions
- Jul 21, 2023Add Verona — ChessMax/awesome-programming-languages0 reactions
- Jul 13, 2023Move the Verona compiler to microsoft/verona — microsoft/Trieste0 reactions
- Oct 24, 2022Optimise for waking an empty queue — microsoft/verona-rt0 reactions
- Oct 24, 2022Token source — microsoft/verona-rt0 reactions
7 more on GitHub
- Oct 20, 2022Small optimisations and refactors around message send and receive — microsoft/verona-rt0 reactions
- Jul 29, 2022Don't run CI on doc-only changes — microsoft/CCF0 reactions · 4 comments
- Aug 26, 2021Enable passthrough to an underlying allocator — microsoft/snmalloc0 reactions · 1 comment
- Jan 25, 2021Meta: Some interesting pointers to borrow ideas — flix/flix0 reactions · 1 comment
- Jan 4, 2021Meta: Some interesting pointers to borrow ideas — HigherOrderCO/Kind0 reactions
- Jun 18, 2020Refactor Pal and LargeAlloc interaction. — microsoft/snmalloc0 reactions
- Jan 27, 2020Automating keeping snmalloc up to date. — SchrodingerZhu/snmalloc-rs0 reactions · 2 comments
On Hacker News · 6
- Jan 17, 2020Microsoft Project Verona: Research programming language for concurrent ownership142 points · 16 comments
- Feb 10, 2020Project Verona FAQ29 points · 8 comments
- Jan 16, 2020Project Verona: Research programming language for concurrent ownership7 points
- Jan 18, 2020Microsoft/Verona3 points
- Dec 14, 2022Concurrent Ownership in Verona2 points
1 more on Hacker News
- Sep 17, 2023Microsoft Project Verona, a research programming language1 point
In this repository19 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- add-testSkill
- debugSkill
- docs-updateSkill
- reviewSkill
- testsuiteSkill
- vbci-memorySkill
- verona-codingSkill
- verona-conventionsSkill
- add-testSkill
- docs-updateSkill
- reviewSkill
- testsuiteSkill
- vbci-memorySkill
- verona-codingSkill
- verona-conventionsSkill
- verona-type-inferenceSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 12 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
Use this skill when working on vc/passes/infer.cc, investigating compile-time type errors rooted in inference, or debugging runtime bad …
- Very specific: line 61
Use exit_envs, not just the merged global environment, when precision matters.
- Distinctive: line 65
Prefer subtyping-aware reasoning over syntactic equality.
- Distinctive: line 103
When diagnosing a bug, first ask which direction is missing.
- Distinctive: line 113
Treat lambda typing as a bidirectional checking problem:
- Very specific: line 120
If the body synthesizes S, acceptance is by subtyping (S <: R), not by rewriting one concrete type tree to another.
- Distinctive: line 122
Do not model lambda result typing as a special-case conversion between two specific return types.
- Distinctive: line 126
Do not confuse that control-flow effect with the lambda's own ordinary result type.
- Distinctive: line 141
Do not assume there is always a principal "best" type independent of context.
- Very specific: line 143
Prefer adding or repairing a propagation path over adding fallback defaults like dyn or any.
- Distinctive: line 158
When changing default-literal logic, validate both compile and runtime behavior.
- Very specific: line 175
Do not mistake nomatch for bottom.
- Distinctive: line 176
Do not add a one-off special case for a single pair of concrete type trees when the real issue is missing contextual checking or subtyping.
- Distinctive: line 178
Do not broaden global subtype rules to patch a local inference bug.
- Very specific: line 179
Do not collapse unresolved cases to any or dyn just to make a later pass accept the program.
- Distinctive: line 181
Do not ignore lambdas when tracing a supposedly "local" inference issue.
- Distinctive: line 182
Do not assume a compile-side improvement is enough.
- Very specific: line 187
Use dist/vc/vc and dist/vbci/vbci, not the non-installed build outputs.
- Distinctive: line 193
When investigating a bug, check:
- Very specific: line 207
If the test compiles, also run dist/vbci/vbci <file>.vbc
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Verona Type Inference
Use this skill when working on vc/passes/infer.cc, investigating compile-time
type errors rooted in inference, or debugging runtime bad type failures caused
by imprecise compiler output.
Mental Model
- Verona type inference is bidirectional refinement, not Hindley-Milner style global unification.
- Information must flow in both directions:
- forward from definitions, annotations, receivers, fields, and callee signatures to uses
- backward from uses, expected result types, stores, and later call sites back to the expressions that produced a value
- Inference is primarily local per function. The main exception is that inference must flow into and out of lambdas within that function.
- Think in terms of checking under context, not just synthesizing from local syntax. Expected types are part of the inference problem, especially for lambdas, default literals, and generic calls.
anyis a top type.- At Verona source inference level, there is no bottom type. Do not treat
nomatch, an empty-looking union, failed shape resolution, or any other artifact as a source-level bottom during inference. Even if later IR or subtype machinery has a bottom-like encoding, that is not a license to inject bottom into source inference.
Literature Anchors
Verona inference is not novel; it is best understood as a combination of known ideas:
- Bidirectional typing (Pierce & Turner; Dunfield & Krishnaswami): use expected types to check introduction forms like lambdas, and synthesize types for elimination forms like calls and lookups.
- Local type inference (Pierce & Turner): infer from nearby syntax, annotations, and use sites instead of trying to recover a single global principal typing.
- Flow-sensitive / occurrence typing (Tobin-Hochstadt & Felleisen style): typetests refine branch-local environments, and joins must preserve soundness.
- Algebraic / semantic subtyping (Frisch, Castagna, Benzaken lineage): unions and intersections are semantic type constructors; subtyping and normalization matter more than raw tree equality.
- Constraint-based generic inference: infer type arguments from actual arguments, receivers, fields, and expected results. With subtyping, intersections, and shapes, principal types often do not exist, so rely on local obligations rather than global search.
Verona-Specific Invariants
- The infer pass runs on ANF, so reason in terms of
LocalIds, labels, and statement-local definitions rather than high-level source syntax. - The engine is organized around a per-function fixpoint over label entry and exit environments.
- Use
exit_envs, not just the merged global environment, when precision matters. Branch-local narrowing often exists only inexit_envs. - The infer pass is not just about compile-time error messages. A missed
refinement can compile and then fail later at runtime with
bad type. - Prefer subtyping-aware reasoning over syntactic equality. Equality checks are only safe where the representation is already canonical and that is the intended invariant.
Key Compiler Hooks
process_function()drives the per-function fixpoint.TypeEnvmapsLocation -> LocalTypeInfo.merge()controls how environments join and how default numeric types are promoted or preserved.trace_typetest()drives branch-local narrowing.infer_call()propagates forward information into calls.backward_refine_call()andbackward_refine_calldyn()propagate expected information backward into earlier calls and dynamic lookups.propagate_shape_to_lambda()is where callable/shape context is pushed into a lambda'sapply.- Return inference in
process_function()must read fromexit_envs, because typetest narrowing can make return types more precise than the global env.
Propagation Directions
Forward propagation
- Parameter types into locals and bodies
- Receiver and method signature information into call arguments
- Explicit annotations into assigned or returned expressions
- Field types into
newarguments and stores - Constructor/member structure into subexpressions
- Typetest results into branch-local envs
Backward propagation
- Expected result types back into prior calls
- Typed stores back into the values being stored
- Typed vars and returns back into producers
- Expected callable types back into lambda params and lambda result obligations
- Later concrete uses back into earlier default-typed numeric literals
When diagnosing a bug, first ask which direction is missing. Many failures look like "inference forgot X" when the real issue is that the needed backward edge or lambda-context edge was never modeled.
Lambdas Are Part of the Local Inference Problem
- Lambdas are the main exception to "per-function local" inference: they are not isolated from their enclosing function.
- Inference must flow into a lambda from an expected callable or shape type, and out of the lambda body via synthesized information and captured uses.
- Treat lambda typing as a bidirectional checking problem:
- the expected callable type provides parameter expectations and a result obligation
- the lambda body still synthesizes information that must be propagated back into the enclosing function's local problem
- For a lambda checked against
(P1, ..., Pn) -> R, the right rule is: parameter types come from the context, and the body must check againstR. If the body synthesizesS, acceptance is by subtyping (S <: R), not by rewriting one concrete type tree to another. - Do not model lambda result typing as a special-case conversion between two specific return types. If a case is valid, it must be valid because it follows the general checking/subtyping rule.
- Remember that
raiseis a non-local return from the enclosing function. Do not confuse that control-flow effect with the lambda's own ordinary result type. - This means that
raisemust be affected by and affect the enclosing function's return type inference, even though it is lexically inside the lambda.
Algebraic, Structural, and Generic Typing
- Verona types are algebraic: unions and intersections are real type constructors, not incidental containers.
- Verona types are structural in the presence of shapes. Matching a shape is about satisfying required structure, not about nominal identity.
- Verona types are generic. Type argument inference should be treated as a local constraint-solving problem driven by actual args, receiver types, field types, and expected results.
- Do not assume there is always a principal "best" type independent of context. With subtyping, intersections, and shapes, context is often essential.
- Prefer adding or repairing a propagation path over adding fallback defaults
like
dynorany.
Default Literals and Delayed Refinement
- Bare numeric literals begin as
DefaultIntorDefaultFloat. - They are placeholders that must be refined from nearby context:
- call parameter types
- variable annotations
- field types in
new - typed stores through refs
- return expectations
- backward propagation from later uses
- A runtime
bad typeoften means a default literal remained unrefined in the compiler output even though enough context existed later. - When changing default-literal logic, validate both compile and runtime behavior. A change that only moves a failure from compile time to runtime is not a fix.
Control Flow and Narrowing
- Branch-local typetest narrowing belongs in branch-local environments.
- Join points must merge information conservatively and soundly.
- Return inference must prefer the more precise per-label environments over a coarser merged environment.
- Watch for oscillation when information can circulate through copies, moves, lookups, or call results. Use monotone propagation patterns when needed.
nomatchis a control-flow artifact in source programs; do not treat it as semantic bottom.
What Not To Do
- Do not mistake
nomatchfor bottom. - Do not add a one-off special case for a single pair of concrete type trees when the real issue is missing contextual checking or subtyping.
- Do not broaden global subtype rules to patch a local inference bug.
- Do not collapse unresolved cases to
anyordynjust to make a later pass accept the program. - Do not ignore lambdas when tracing a supposedly "local" inference issue.
- Do not assume a compile-side improvement is enough; validate runtime too.
Debugging Workflow
- Build with
ninja install. - Use
dist/vc/vcanddist/vbci/vbci, not the non-installed build outputs. - Dump passes with
--dump_passes=<dir>and compare at least:07_anf.trieste08_infer.trieste09_reify.trieste13_typecheck.trieste
- When investigating a bug, check:
- where the value first became default-typed or imprecise
- where an expected type first became available
- whether the needed backward edge exists
- whether lambda context was propagated
- whether
exit_envspreserve branch narrowing - whether reify/typecheck is only exposing an earlier infer precision bug
- Compare a failing test with a nearby passing one to isolate the missing refinement path.
Validation Checklist
cd build && ninja install- Reproduce with
dist/vc/vc build ../testsuite/v/<name> --dump_passes=<dir> - If the test compiles, also run
dist/vbci/vbci <file>.vbc - Run focused
ctest --output-on-failure -R '<pattern>' - Then run broader
ctest --output-on-failure -j$(nproc)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

