Open tjpalmer opened 3 months ago
Personally, I think I vote for just removing this warning/error message for now, or else put it on "fine" logging level or something.
I'm not sure if we should elide the as<>()
or if it's still helpful for any backends in odd cases. But that could be a separate PR from the one that reduces the log level for this message.
I can turn it off. I imagine we could redo it as a linter thing if it turns out to have no effect on type inference.
I got some cases where the cast is to the same type. We probably still can error/warn on this case but maybe with different text:
95: var regex = base.as<Sequence>();
┗━━━━━━━━━━━━━━━━━┛
[-work//tostring.temper:95+18-37]@G: Unnecessary type check to Sequence from expression with type Sequence which is a subtype
Here's example code from temper-regex-parser that uses a cast to ensure we see
List<Pair<String, RegexNode>>
rather thanList<Pair<String, RegexNode>>
:But we now get this error when building that we didn't used to get:
Used to be error free. And without that cast, we get even more errors:
In both cases, all tests pass on working backends (currently just csharp, js, & lua).
I can try this alternative:
But it still has an error:
Casting the entire map has errors also.
Or in other words, I don't know a way to avoid error messages now on something that used to work.
We could either be more clever went to present the new error or else remove the error or else move sooner in avoiding "or" types or else improved unifying of types in generic collections or such like.