Fix scope_type method

Bindings in some cases may be nil, raising an exception.