tools/intrinsic: Fix validation for type matchers
The tooling does not expect, nor can handel a type matcher to be used as a parameter or a direct template parameter to another type. Make this an error. Change-Id: I28c04c00c7fa1cb5130c53215a90a59d660d6fa3 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114380 Reviewed-by: Antonio Maiorano <amaiorano@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
5addefb148
commit
55ceebec1e
|
@ -352,7 +352,7 @@ func (r *resolver) intrinsic(
|
|||
case ast.Builtin, ast.Operator:
|
||||
overload.ConstEvalFunction = overload.Decl.Name
|
||||
case ast.Initializer:
|
||||
overload.ConstEvalFunction = "init"
|
||||
overload.ConstEvalFunction = "Init"
|
||||
case ast.Converter:
|
||||
overload.ConstEvalFunction = "Conv"
|
||||
}
|
||||
|
@ -448,12 +448,15 @@ func (r *resolver) intrinsic(
|
|||
}
|
||||
|
||||
// fullyQualifiedName() resolves the ast.TemplatedName to a sem.FullyQualifiedName.
|
||||
// The resolved name cannot be a TypeMatcher
|
||||
func (r *resolver) fullyQualifiedName(s *scope, arg ast.TemplatedName) (sem.FullyQualifiedName, error) {
|
||||
target, err := r.lookupNamed(s, arg)
|
||||
if err != nil {
|
||||
return sem.FullyQualifiedName{}, err
|
||||
}
|
||||
|
||||
if _, ok := target.(*sem.TypeMatcher); ok {
|
||||
return sem.FullyQualifiedName{}, fmt.Errorf("%v type matcher cannot be used directly here. Use a matcher constrained template argument", arg.Source)
|
||||
}
|
||||
fqn := sem.FullyQualifiedName{
|
||||
Target: target,
|
||||
TemplateArguments: make([]interface{}, len(arg.TemplateArgs)),
|
||||
|
|
|
@ -86,13 +86,6 @@ fn f<T: m>(P<T>) -> T`,
|
|||
success,
|
||||
}, {
|
||||
`
|
||||
type f32
|
||||
type P<T>
|
||||
match m: f32
|
||||
fn f(P<m>)`,
|
||||
success,
|
||||
}, {
|
||||
`
|
||||
enum e { a }
|
||||
match m: e.a
|
||||
fn f(m)`,
|
||||
|
@ -511,6 +504,20 @@ enum E { a b }
|
|||
match m: E.a | E.b
|
||||
conv F<M: m>(P<M>)`,
|
||||
`file.txt:4:16 cannot use template enum 'E' as template number`,
|
||||
}, {
|
||||
`
|
||||
type f32
|
||||
type P<T>
|
||||
match m: f32
|
||||
fn f(m)`,
|
||||
`file.txt:4:6 type matcher cannot be used directly here. Use a matcher constrained template argument`,
|
||||
}, {
|
||||
`
|
||||
type f32
|
||||
type P<T>
|
||||
match m: f32
|
||||
fn f(P<m>)`,
|
||||
`file.txt:4:8 type matcher cannot be used directly here. Use a matcher constrained template argument`,
|
||||
},
|
||||
} {
|
||||
|
||||
|
|
Loading…
Reference in New Issue