Skip to content

Honour mapped types on conversion targets - #129

Open
jsboige wants to merge 1 commit into
endjin:mainfrom
MyIntelligenceAgency:fix/mapped-type-conversion-current
Open

jsboige wants to merge 1 commit into
endjin:mainfrom
MyIntelligenceAgency:fix/mapped-type-conversion-current

Conversation

@jsboige

@jsboige jsboige commented Nov 24, 2026 •

Copy link
Copy Markdown

Summary

  • Resolve TheoremVariableTypeMappingAttribute before selecting a conversion target sort.
  • Permit only the typed identity conversion promised by that mapping; arbitrary mapped instances remain unsupported.
  • Add MSTest/Shouldly coverage for cast constants, arithmetic between mapped symbols, constructor read-back, and the unsupported-instance control.

Reproduction

On current endjin/main 964f17704e38399e6ad15a971d3d5aee61fcfb32, the first regression test fails with:

System.NotImplementedException: Cast '2,5 (System.Double)' to ... ExactReal
  at Z3.Linq.ExpressionVisitor.VisitConvert(...)

The same mapped type already solves as an environment symbol, but VisitConvert uses TypeCode.Object and cannot select a sort.

Verification

  • Red on 964f177: Solve_ConstantCastToMappedType_TranslatesUsingTheMappedSort, 0 passed / 1 failed.
  • Green after this change: 4 targeted tests passed on net10.0.
  • Full suite: 372/372 passed on net10.0.
  • No net8.0 leg exists upstream, by construction: at 964f17704e, solutions/Directory.Build.props sets <TargetFramework>net10.0</TargetFramework> for every project, Z3.Linq.csproj declares no target of its own, and CI installs dotnet-version: '10.x'. There is no net8.0 target here to validate against; the target mismatch met in an earlier net8.0 attempt was that absence, not an unverified part of this patch.

Downstream note, for anyone cherry-picking onto a tree that multi-targets net8.0 and evaluates the whole constraint before translating it: there (ExactReal)2.5 is folded into a constant of the mapped type before VisitConvert is reached, so this patch alone leaves those tests red, and the fork adds a guard that skips that fold for such constraints (MyIntelligenceAgency#50: suite 475/475 on net10.0 and net8.0 with it). Upstream hands the conversion node to the visitor as written — its red run above fails inside VisitConvert — so nothing here depends on that guard.

Part of jsboige/CoursIA#19237 (G4 follow-up for MyIntelligenceAgency#40). This PR does not merge or close #40.

🤖 Generated with Claude Code

Resolve mapped target types before selecting a conversion sort. Accept only the typed identity operator promised by the mapping and keep arbitrary mapped instances unsupported.

Add red/green coverage for cast constants, arithmetic and constructor read-back.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Lane: myia-po-2023:CoursIA
jsboige added a commit to MyIntelligenceAgency/Z3.Linq that referenced this pull request Nov 24, 2026
Twenty consumer notebooks executed with 235/235 cells and no errors. The mapped conversion defect reproduces on upstream main and is proposed as endjin#129.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Lane: myia-po-2023:CoursIA
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