Skip to content

fix(compiler): preserve templated scalar initializer types - #12510

Draft
Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 1 commit into
microsoft:mainfrom
sylvesterkaczmarek:fix/12506-templated-scalar-initializers
Draft

Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 1 commit into
microsoft:mainfrom
sylvesterkaczmarek:fix/12506-templated-scalar-initializers

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Summary

Fixes #12506.

Keep scalar initializer lookup bound to the instantiated scalar, including aliases and inherited constructors. Resolve initializer parameters with the active template mapper instead of reusing an unresolved declaration-level parameter. Existing assignability rules are unchanged.

Add regressions for the reported assignment, exact scalar identity, multiple instantiations in either order, default arguments, scalar/constructor aliases, inherited initializers, and invalid argument types. Include a compiler changelog entry. No dependency or lockfile changes.

Validation

  • Full workspace pnpm test --maxWorkers=4: 10,670 passed, 25 skipped across 500 passing files and one skipped file.
  • Compiler end-to-end suite: 45 passed.
  • Full pnpm build: 48 tasks successful, including engineering type checks and compiler external-signature generation.
  • Full formatter and type-aware lint passed, with zero lint warnings or errors.
  • Before the fix, the focused three-file run had 14 failed and 33 passed; the same run passes all 47 tests with the fix. Expanded related coverage passed 772 tests.
  • Independent pre-submission review found no actionable defects; its 888 focused repository tests and 30 additional probes passed.
  • The built CLI accepts the exact issue reproduction and still rejects Test<string>.from(123) through a scalar alias with the expected invalid-argument diagnostic.

Validated on macOS arm64 with the repository-pinned Node 26.5.1 and pnpm 11.10.0. Full validation ran in an identical-source isolated checkout to avoid unrelated home-directory module resolution. Source hashes match the submitted files. Hosted CI and maintainer review remain pending.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label Nov 6, 2026

This branch has not been deployed

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

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Templated scalar value assignment issue

1 participant