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

Unused template parameter silently ignored #181

Open
mikekistler opened this issue Jan 17, 2022 · 10 comments · May be fixed by #5494
Open

Unused template parameter silently ignored #181

mikekistler opened this issue Jan 17, 2022 · 10 comments · May be fixed by #5494
Assignees
Labels
ide Issues for VS, VSCode, Monaco, etc.
Milestone

Comments

@mikekistler
Copy link
Member

No diagnostic is issues for a templated model with a template parameter that is not used.

For example:

model Response<S, B> {
  @doc("The status code.")
  @statusCode
  _: S;
}

model Cat {
  meow: int32;
}

@route("/")
namespace root {
  op read(): Response<200, Cat>;
}

compiles with no diagnostic messages.

@markcowl
Copy link
Contributor

markcowl commented Jan 21, 2022

  • language server should dim unused parameters

@nguerrera
Copy link
Contributor

I will need to investigate how TS does this to estimate. One way would be some sort of off-by-default diagnostic that we render as dimming, I think. We will need the compiler to tell us what is unused somehow.

@nguerrera
Copy link
Contributor

Do we want there to be an actual diagnostic for this or only dimming in the IDE?

@mikekistler
Copy link
Member Author

My recollection from the design discussion is that we don’t want a diagnostic — just dimming in the IDE.

@markcowl
Copy link
Contributor

@bterlson Is this fixed, or should we move to backlog?

@allenjzhang
Copy link
Member

Diming is good. For reference C# does not throw warning for unused template parameters.

@bterlson
Copy link
Member

This is not fixed, can be moved to backlog.

@markcowl markcowl added this to the Backlog milestone Feb 25, 2022
@nguerrera nguerrera added the ide Issues for VS, VSCode, Monaco, etc. label Mar 10, 2022
@RodgeFu
Copy link
Contributor

RodgeFu commented Jun 4, 2024

the dimming is done through diagnostic with DiagnosticTag.Unnecessary tag. It will be good to have linter to report all kinds of unused stuff in general. related issue: #2196, #3373

@RodgeFu RodgeFu self-assigned this Nov 13, 2024
@RodgeFu RodgeFu assigned RodgeFu and chunyu3 and unassigned RodgeFu Dec 12, 2024
@chunyu3
Copy link
Contributor

chunyu3 commented Dec 26, 2024

add one special template parameter case: In this case, the template argument NameTemplate is used in decorator

@friendlyName(NameTemplate, T)
@withVisibilityFilter(#{ any: #[Lifecycle.Create, Lifecycle.Update] })
model CreateOrUpdate<
  T extends Reflection.Model,
  NameTemplate extends valueof string = "CreateOrUpdate{name}"
> {
  ...T;
}

@chunyu3
Copy link
Contributor

chunyu3 commented Dec 26, 2024

Shall we support other template beside model template:
operation template,
scale template,
Alias template,
Union template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ide Issues for VS, VSCode, Monaco, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants