microsoft / microsoft/qdk

Preserve declarations with unsatisfied @Config attributes

Open
#3,449 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs triage
Dominant language
Rust
Stars
1k
Forks
212
Avg merge
3d 8h
Merged PRs (30d)
65

Description

A simulation-only function like `Std.Random.DrawRandomInt` is annotated with a `@Config` attribute (in this case, `@Config(Unrestricted)`) to indicate that it shouldn't be available unless a suitable profile has been selected. Such functions are filtered out quite early in the compilation process (AST probably?) with the result that the design time error is "unresolved name". It would be much more user friendly to resolve the name and then explain why it's not available. Besides improving the error experience, this would make features like Quick Info and Go-to-Def available.

There's a substantial wrinkle: we don't use config only to remove unavailable functionality. Sometimes, multiple implementations are provided - for example, a simple one for Base profile and a more efficient one for Adaptive. If multiple implementations have unsatisfied config attributes, it's much less clear which to resolve in the editor.

One direction to consider might be to introduce an internal concept of stub/skeleton/declaration-only signatures without bodies. This would retain the benefit of not having to compile the implementation, while also keeping it available at design time.

In the interim, we might be able to hack the multiple implementations case by having an unconditionally available function that calls one of multiple conditionally available (i.e. depending on the profile) inner functions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing where functions with unsatisfied @Config attributes are filtered during AST or early compilation, then examine how design-time name resolution handles multiple conditional implementations. Done means declarations remain available for diagnostics, Quick Info, and Go-to-Def while unavailable implementations are still excluded from compilation and ambiguous implementations have a defined resolution strategy.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, quantum-computing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.