Repository navigation
csharp: new T() on a staged library type is not an external constructor (#1339) - #2025
Merged
Merged
Conversation
swapnilpaliwal-sd
requested review from
JaredHLZhang,
Whua689 and
suyashpaliwal26
as code owners
November 18, 2026 23:07
…or (#1339) With a C# library staged, `new Store()` on a library type was still reported as a construction of an unstaged dependency. Declared constructor: the site had two rows, the resolved one and `external:Store.<constructor>` (provenance external). The cause is call_ctor_target_accepts in external-types.dl, which re-checked that the target accepts the argument count under the SITE's provenance. A client site that reaches a library constructor has the constructor under "lib", so the check found nothing and the "staged type, no carried constructor" clause labelled a resolved site as unstaged. call_ctor_target already checks the arity under the constructor's own provenance, so the relation now reads it as is. No constructor carried: the site was `external:Store.<constructor>`, which says the dependency was not supplied. It now has one row to `generated:<qualified type name>#<constructor>/0` with callee_provenance lib and tier boundary_lib; the bundle gives that id a methods row with provenance generated, as it does for a delegate member's Invoke. `new T()` compiles only if T has a parameterless constructor, so the target exists, but a library IR is a signature subset and cannot say whether T declares it, so the site is still kept out of known_implicit_ctor. A site whose argument count no carried constructor accepts, where the IR carries some, keeps its external label, like an uncarried method. Tests: staging-test.sh gains both shapes; it fails on the base (2 rows / external) and passes here.
… keeps its own version) 0.2.3 is released, so what merges into this branch ships in 0.2.4. package.json (version and the five @axiomcode/engine-* pins) and the four editor plugin and extension manifests move from 0.2.3 to 0.2.4. The parser keeps its own version.
…harp-staged-ctor-not-external
Merged
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.
Fixes #1339
Summary
With a C# library staged through
--library,new Store()on a library type was still reported as a construction of an unstaged dependency. Both shapes from the issue still reproduced on0.2.4:Storein the staged librarypublic Store() { }external:Store.<constructor>(provenanceexternal)external:Store.<constructor>(provenanceexternal)generated:Acme.Store#<constructor>/0, provenancelib, tierboundary_libtype_name_unresolvedas the issue guessed: the external clause keyed on it needs!expr_new_type, and the type does resolve. It is the "staged type whose constructor is not carried" clause inexternal-types.dl, which is gated on!call_ctor_target_accepts(prov, e, ac). That relation re-checkedctor_accepts_argcunder the site's provenance (client), while a staged constructor is declared underlib, so it never held for a clientnewreaching a library constructor, and a resolved site was also labelled unstaged.call_ctor_targetalready admits a constructor only where it accepts the argument count, under the provenance the constructor is declared in, socall_ctor_target_acceptsnow reads it as is.externalon a staged type with no carried constructor.new T()compiles only ifThas a parameterless constructor, declared or compiler-supplied, so the target exists and belongs to a type the run was given. A new relation,staged_parameterless_ctor, names itgenerated:<qualified type name>#<constructor>/0. The bundle already gives agenerated:id amethodsrow (provenancegenerated, owner the type), as it does for a delegate member'sInvoke. The edge iscallee_provenance = lib, tierboundary_lib. The site still stays out ofknown_implicit_ctor: a library IR is a signature subset, so it cannot show the type declares no constructor (call_ctor_implicitis unchanged).A
newwhose argument count no carried constructor accepts, where the IR does carry some constructor, keeps itsexternal:label, the same as an uncarried method on a staged type.Review these first
graph/csharp/engine/resolution/external-types.dl:call_ctor_target_accepts, the newstaged_parameterless_ctor, and the!staged_parameterless_ctorguard on the staged-type constructor clause.graph/csharp/engine/call-edge-generation/call_chain.dl: thestaged_parameterless_ctoredge, plus itssite_leaves_clientandcall_has_edgeclauses. Withoutcall_has_edge, the site also kept a- - boundary_librow.graph/bundle/schema.ts(and the regeneratedSCHEMA.md):methods.provenance = generatedandcall_edges.callee_provenance = libfor C# now mention the constructor node.Tests
graph/test/csharp/staging-test.shadds the issue's repro in both shapes, each with its own staged library. On the base it fails both checks (the declared constructor gives 2 rows, 1 of them external; no constructor gives an external row). Here it passes.graph/test/csharp/run-tests.sh: cases scored against the Roslyn oracle,staging-test.sh,tools/*-test.shincludinglibrary-resolution-test.sh): oracle self-test 7/7, cases 22/22 (100% cover / agree / fan each), staging PASS, all 10 tools gates ok, exit 0.graph/test/tools/bundle-test.shpasses (schema doc current).gen_decls_all.py --checkis clean.lib_*relation empty, and every new clause needs alibtype, so it cannot fire there.