Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: There's seemingly no way to see what arguments were actually specified vs defaulted for a template instantiation #5449

Open
4 tasks done
TomerAberbach opened this issue Dec 26, 2024 · 0 comments
Labels
bug Something isn't working needs-area

Comments

@TomerAberbach
Copy link
Contributor

Describe the bug

For example, suppose you have the following:

model TemplateModel<A, B = string> {
  a: A,
  b: B
}

model InstantiatedModel1 is TemplateModel<int32>;
model InstantiatedModel2 is TemplateModel<int32, string>;

As far as I can tell, there's nothing in the TypeSpec AST that lets me differentiate between TemplateModel<int32> and TemplateModel<int32, string>. In both cases the second argument is considered to be string and there's no simple indication that in one case it was from a default and in the other case it was explicitly specified.

This matters for my use-case because I'm generating functions for templated models (see TomerAberbach/typespec-fast-check#76 if you're curious) and it would be nice to make the emitted function calls (i.e. template instantiations) not unnecessarily emit default arguments that were not specified in the TypeSpec file.

Related to #5448.

Reproduction

See above.

Checklist

@TomerAberbach TomerAberbach added the bug Something isn't working label Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-area
Projects
None yet
Development

No branches or pull requests

1 participant