Fix global opaque val segfault, addresses BIT-1071

The opaque types need to be created before scripts are parsed.