Skip to content

fix(typecheck): lenient deref for ref-mode params (#128)#190

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/128-lenient-deref
May 18, 2026
Merged

fix(typecheck): lenient deref for ref-mode params (#128)#190
hyperpolymath merged 1 commit into
mainfrom
fix/128-lenient-deref

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

ref/mut params lower to their bare value type (borrow checker tracks the borrow), but OpDeref forced the operand to unify with TRef tv — so stdlib reading ref params via *self/*other (traits.affine Eq/Ord/Hash/Display for Int/Bool) failed Unify (ref tv, Int).

*e now peels one borrow layer for TRef/TMut/TOwn and is the identity on value types. Real refs still deref; value types unchanged.

  • stdlib 16 → 17/19 (traits.affine green)
  • dune test 233/233, zero regression

Refs #128

Params declared with a ref/mut mode (e.g. `ref self`, `ref other: Int`)
are lowered to their bare value type — the borrow checker tracks the
actual borrow, not the type. But OpDeref required the operand to unify
with `TRef tv`, so stdlib code reading ref params via `*self`/`*other`
(traits.affine Eq/Ord/Hash/Display impls for Int/Bool) failed with
`Unify (ref tv, Int)`.

Make `*e` peel one borrow layer when e is TRef/TMut/TOwn and act as the
identity on a value type. Real reference types still deref to inner;
value types unchanged -> no regression.

stdlib 16->17/19; 233/233 dune test, zero regression.

Refs #128

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath hyperpolymath merged commit d762884 into main May 18, 2026
11 of 12 checks passed
@hyperpolymath hyperpolymath deleted the fix/128-lenient-deref branch May 18, 2026 03:43
@github-actions
Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 44 issues detected

Severity Count
🔴 Critical 12
🟠 High 21
🟡 Medium 11

⚠️ Action Required: Critical security issues found!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant