typespec icon indicating copy to clipboard operation
typespec copied to clipboard

[Bug]: mutator does not work for scalar type's templated arguments

Open tadelesh opened this issue 7 months ago • 2 comments

Describe the bug

see the original issue: https://github.com/Azure/typespec-azure/issues/2684

Reproduction

write a templated scalar and mutate the type to see if the passed templated arguments are mutated.

Checklist

tadelesh avatar May 15 '25 10:05 tadelesh

@tadelesh We couldn't repro this with arguments passed to a decorator, can you elaborate on the specific scenario that is blocked that requires inspecting the arguments to the scalar type?

markcowl avatar May 16 '25 20:05 markcowl

it is happened for this type. when we get state from the parameterizedNextLinkConfig decorator of a mutated type, the returned type of ParameterizedParams is not mutated.

tadelesh avatar May 17 '25 01:05 tadelesh

So I think there is first an issue with that type. You shouldn't be checking the template arguments(apart as a workaround for missing feature)

@Azure.Core.Foundations.Private.parameterizedNextLinkConfig(TypeSpec.Reflection.ModelProperty[])
scalar parameterizedNextLink<ParameterizedParams extends TypeSpec.Reflection.ModelProperty[]>
  extends url;

but should be

@Azure.Core.Foundations.Private.parameterizedNextLinkConfig(ParameterizedParams)
scalar parameterizedNextLink<ParameterizedParams extends TypeSpec.Reflection.ModelProperty[]>
  extends url;

then you get that as teh decorator param and don't need to check the templateArguments.

They might not be mutated and that probably needs to be fixed but I think this is a first a misuse of the type graph on the tcgc side.

timotheeguerin avatar May 21 '25 18:05 timotheeguerin

Closing as it was

  1. a misue on the side of the decorator
  2. Decorator was actually using templateArguments which was a deprecated and now removed property which would explain why the mutator didn't mutate it Fixed the decorator correctly here https://github.com/Azure/typespec-azure/pull/2730

timotheeguerin avatar May 23 '25 17:05 timotheeguerin

@timotheeguerin i tested your latest change and found the template parameter used in decorator is not mutated. i reopened this issue and change the title.

tadelesh avatar May 26 '25 08:05 tadelesh

add a new test in tcgc to repro the issue: https://github.com/Azure/typespec-azure/pull/2734

tadelesh avatar May 26 '25 08:05 tadelesh

hhm its weird, works fine with the @doc decorator but that decorator parameters seems to not be mutated

timotheeguerin avatar May 27 '25 15:05 timotheeguerin

ah seems to maybe be tuples

timotheeguerin avatar May 27 '25 15:05 timotheeguerin