Naga can't produce spans for references to local variables #7498
Labels
area: naga middle-end
Intermediate representation
kind: diagnostics
Error message should be better
naga
Shader Translator
Naga can't produce spans for expressions that are simply uses of local variables.
Given the following WGSL:
Naga's error message is:
If we instead pass a literal
0i
, then Naga can actually point at the argument and tell us what its type is:The root of the problem is that Naga IR says that each function body should only have a single
LocalVariable
expression, which produces a pointer to the variable, and then all accesses, loads, and stores should point to that. Because all references to the local variable are actually the sameir::Expression
, the arena can only associate a single span with all of them. Pointing at the definition would be better than this, but for goodness' sake, this is not rocket science - Naga should just point at the expression proper.I think this was kind of a SPIR-V inspired idea, but it just doesn't make sense for Naga. To the best of my knowledge, we never take advantage of the uniqueness of
LocalVariable
expressions. It would be completely fine for us to just emit a separateExpression::LocalVariable
for each use. Then the expression arena could store a separate span for each use.The text was updated successfully, but these errors were encountered: