Closed carlini closed 3 years ago
Ah well. This is interesting, and is going to have to be a bigger PR than the trivial change I'd thought:
Replicate() assigns a variable of a different shape, but this needs to be allowed.
Some of the other tests abuse this feature and need to be fixed.
It looks like the test has stalled (or is taking >12 hours)
Huh. I'm not sure how I got in that state, but it wasn't intended.
Ah well. I've just completely messed up my local state. I'm going to close this PR and re-open one with a clean history.
This PR asserts that the shape of a variable isn't changed when assigning to it. Most of it is fairly uncontroversial (#106).
However I do one further thing. In order for the error message when restoring a variable show the name of the variable that caused the error, I add some additional state to BaseVar to support this. As a result, if restore fails, it won't just say that some variable had the wrong shape, but now it will error with exactly which variable did.
The other way to do this would be to wrap the restore assign() in a try/catch and then repeat the error, but with the name attached. The benefit of this approach is the error isn't duplicated, but it's a bit more code.
(I also imagine that having the variable name could help for some other errors in the future.)