Fix bug with transient value casting