mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Contract on trying to use Object without initializing it.
This commit is contained in:
@@ -186,6 +186,9 @@ fn void Object.set_object(&self, String key, Object* new_object) @private
|
|||||||
self.map.set(key, new_object);
|
self.map.set(key, new_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@require self.allocator != null : "This object is not properly initialized, was it really created using 'new'"
|
||||||
|
*>
|
||||||
macro Object* Object.object_from_value(&self, value) @private
|
macro Object* Object.object_from_value(&self, value) @private
|
||||||
{
|
{
|
||||||
var $Type = $typeof(value);
|
var $Type = $typeof(value);
|
||||||
@@ -201,7 +204,7 @@ macro Object* Object.object_from_value(&self, value) @private
|
|||||||
$case $Type.typeid == Object*.typeid:
|
$case $Type.typeid == Object*.typeid:
|
||||||
return value;
|
return value;
|
||||||
$case $Type.typeid == void*.typeid:
|
$case $Type.typeid == void*.typeid:
|
||||||
if (value != null) return TYPE_MISMATCH?;
|
if (value != null) TYPE_MISMATCH?!;
|
||||||
return &NULL_OBJECT;
|
return &NULL_OBJECT;
|
||||||
$case $assignable(value, String):
|
$case $assignable(value, String):
|
||||||
return new_string(value, self.allocator);
|
return new_string(value, self.allocator);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
- Fix regression in Time diff due to operator overloading #2124.
|
- Fix regression in Time diff due to operator overloading #2124.
|
||||||
- attrdef with any invalid name causes compiler assert #2128.
|
- attrdef with any invalid name causes compiler assert #2128.
|
||||||
- Correctly error on `@attrdef Foo = ;`.
|
- Correctly error on `@attrdef Foo = ;`.
|
||||||
|
- Contract on trying to use Object without initializing it.
|
||||||
|
|
||||||
### Stdlib changes
|
### Stdlib changes
|
||||||
- Added `String.quick_ztr` and `String.is_zstr`
|
- Added `String.quick_ztr` and `String.is_zstr`
|
||||||
|
|||||||
Reference in New Issue
Block a user