mirror of
https://github.com/godotengine/godot.git
synced 2025-10-22 01:13:39 +00:00
GDScript: Properly validate return type
When the type cannot be validated at compile time, the runtime must do a check to ensure type safety is kept, as the code might be assuming the return type is correct in another place, leading to crashes if the contract is broken.
This commit is contained in:
parent
655a913e22
commit
35682d3079
4 changed files with 304 additions and 6 deletions
|
@ -761,6 +761,39 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
|
|||
|
||||
incr = 2;
|
||||
} break;
|
||||
case OPCODE_RETURN_TYPED_BUILTIN: {
|
||||
text += "return typed builtin (";
|
||||
text += Variant::get_type_name((Variant::Type)_code_ptr[ip + 2]);
|
||||
text += ") ";
|
||||
text += DADDR(1);
|
||||
|
||||
incr += 3;
|
||||
} break;
|
||||
case OPCODE_RETURN_TYPED_ARRAY: {
|
||||
text += "return typed array ";
|
||||
text += DADDR(1);
|
||||
|
||||
incr += 5;
|
||||
} break;
|
||||
case OPCODE_RETURN_TYPED_NATIVE: {
|
||||
text += "return typed native (";
|
||||
text += DADDR(2);
|
||||
text += ") ";
|
||||
text += DADDR(1);
|
||||
|
||||
incr += 3;
|
||||
} break;
|
||||
case OPCODE_RETURN_TYPED_SCRIPT: {
|
||||
Variant script = _constants_ptr[_code_ptr[ip + 2]];
|
||||
Script *sc = Object::cast_to<Script>(script.operator Object *());
|
||||
|
||||
text += "return typed script (";
|
||||
text += sc->get_path();
|
||||
text += ") ";
|
||||
text += DADDR(1);
|
||||
|
||||
incr += 3;
|
||||
} break;
|
||||
|
||||
#define DISASSEMBLE_ITERATE(m_type) \
|
||||
case OPCODE_ITERATE_##m_type: { \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue