microsoft / typespec

https://typespec.io/
MIT License
4.51k stars 216 forks source link

Diagnostics stacktrace #1321

Open timotheeguerin opened 1 year ago

timotheeguerin commented 1 year ago

We should find a way to show the diagnostics happening in template instance at a better location

There is a lot of validation that cannot be represented right now as template constraints and even if we supported most there is probably still some things that are out of control.

model Foo<T> {
  @format("uri")
  foo: T;
          ^ error shows up here saying `int32`is not valid for `@format`
}

op test(): Foo<int32>;

https://cadlplayground.z22.web.core.windows.net/?c=bW9kZWwgRm9vPFQ%2BIHsKICBAZm9ybWF0KCJ1cmkiKQogIGZvbzogVDsKfQoKb3AgdGVzdCgpOsUyaW50MzI%2BOw%3D%3D

Some options could be tracing back to out of the template instance to where the template was instantiated.

nguerrera commented 1 year ago

See also https://github.com/microsoft/cadl/issues/423#issuecomment-1092258317 for example from other compiler.

markcowl commented 1 year ago

@timotheeguerin Add implementation sketch and estimate

markcowl commented 1 year ago

pri: 2