fix(typecheck): instantiate constructor schemes per use-site in patterns (#128)#187
Merged
Merged
Conversation
…rns (#128) check_pattern's PatCon read the monomorphic constructor_env entry and wrapped it as a 0-tyvar scheme, so every occurrence of a constructor shared one set of type variables. Two `Ok(_)` patterns in a single match (e.g. result.affine `apply`'s tuple match) thus forced both payloads to the same type, yielding `Unify ((_ -> _), T)`. Now prefer the polymorphic scheme bound in name_types (set via bind_scheme for builtin Ok/Err/Some/None/RuntimeError and user variants) and instantiate it fresh per occurrence — exactly as lookup_var does for ordinary identifiers — falling back to the constructor_env entry only when no scheme is registered. Correctness/soundness fix. Full suite 233/233, zero regression. (result.affine remains blocked on a separate import-path issue: imported parametric ctor schemes are built with fresh_tyvar 0 then generalize, a no-op at level 0 — tracked for the next slice.) Refs #128. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🔍 Hypatia Security ScanFindings: 44 issues detected
View findings[
{
"reason": "Stray AI.a2ml in root -- use 0-AI-MANIFEST.a2ml only",
"type": "banned",
"file": "AI.a2ml",
"action": "delete",
"rule_module": "root_hygiene",
"severity": "high"
},
{
"reason": "Superseded by 0-AI-MANIFEST.a2ml",
"type": "banned",
"file": "AI.djot",
"action": "delete",
"rule_module": "root_hygiene",
"severity": "high"
},
{
"reason": "Issue in quality.yml",
"type": "missing_workflow",
"file": "quality.yml",
"action": "create",
"rule_module": "workflow_audit",
"severity": "high"
},
{
"reason": "Issue in security-policy.yml",
"type": "missing_workflow",
"file": "security-policy.yml",
"action": "create",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
"type": "unpinned_action",
"file": "governance.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "high"
},
{
"reason": "TypeScript file detected -- banned language",
"type": "banned_language_file",
"file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/example/smoke_driver.ts",
"action": "flag",
"rule_module": "cicd_rules",
"severity": "critical"
},
{
"reason": "TypeScript file detected -- banned language",
"type": "banned_language_file",
"file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/cli.ts",
"action": "flag",
"rule_module": "cicd_rules",
"severity": "critical"
},
{
"reason": "TypeScript file detected -- banned language",
"type": "banned_language_file",
"file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/mod.ts",
"action": "flag",
"rule_module": "cicd_rules",
"severity": "critical"
},
{
"reason": "TypeScript file detected -- banned language",
"type": "banned_language_file",
"file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/lib/compile.ts",
"action": "flag",
"rule_module": "cicd_rules",
"severity": "critical"
},
{
"reason": "TypeScript file detected -- banned language",
"type": "banned_language_file",
"file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/lib/runner.ts",
"action": "flag",
"rule_module": "cicd_rules",
"severity": "critical"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
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.
STAGE A (#128/#135). Soundness fix.
check_pattern'sPatConread the monomorphicconstructor_enventry and wrapped it as a 0-tyvar scheme, so every occurrence of a constructor shared one set of type variables. TwoOk(_)patterns in a single match (e.g.result.affine'sapplytuple match) forced both payloads to the same type →Unify ((_ -> _), T).Now prefer the polymorphic scheme in
name_types(set viabind_schemefor builtinOk/Err/Some/None/RuntimeErrorand user variants) and instantiate it fresh per occurrence — exactly aslookup_vardoes for ordinary identifiers — falling back toconstructor_envonly when no scheme is registered.Full suite 233/233, zero regression.
result.affineremains blocked on a separate import-path issue (imported parametric ctor schemes built withfresh_tyvar 0thengeneralize, a no-op at level 0) — next slice. Refs #128.