Lunderberg opened a new pull request, #12691:
URL: https://github.com/apache/tvm/pull/12691

   Prior to this commit, the following code would compile and run without 
error.  This occurs because the typed `Array<T>::insert` calls the untyped 
`ArrayNode::InitRange`, with no type-checking done before the call.
   
   ```c++
   Var x("x");
   Var y("y");
   Array<Var> var_arr{x, y};
   Array<PrimExpr> expr_arr{x + 1, y + 2};
   // Erroneously inserts static-type PrimExpr, runtime-type Add, even
   // though neither PrimExpr is a type of Var.
   var_arr.insert(var_arr.begin(), expr_arr.begin(), expr_arr.end());
   ```
   
   After this commit, a `static_assert` in `Array<T>::insert` and in 
`Array<T>::Array(IterType,IterTYpe)` restricts the iterators, such that they 
must dereference to `T`, `Optional<T>`, a subclass of `T`, or `Optional<U>` 
where `U` is a subclass of `T`.
   
   The public method `ArrayNode::SetItem` exposes a similar issue.  In the 
future, we may want to make it be private, accessed only through type-safe 
method in `Array<T>::Set`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to