mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Add contract on any_to_enum_ordinal and any_to_int to improve error when passed an empty any. #2977
This commit is contained in:
@@ -317,6 +317,9 @@ macro any.retype_to(&self, typeid type)
|
|||||||
return $$any_make(self.ptr, type);
|
return $$any_make(self.ptr, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<*
|
||||||
|
@require (bool)self.type : "A typed any was expected"
|
||||||
|
*>
|
||||||
macro any.as_inner(&self)
|
macro any.as_inner(&self)
|
||||||
{
|
{
|
||||||
return $$any_make(self.ptr, self.type.inner);
|
return $$any_make(self.ptr, self.type.inner);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ faultdef VALUE_OUT_OF_RANGE, VALUE_OUT_OF_UNSIGNED_RANGE;
|
|||||||
|
|
||||||
<*
|
<*
|
||||||
@require $Type.kindof.is_int() : "Type was not an integer"
|
@require $Type.kindof.is_int() : "Type was not an integer"
|
||||||
|
@require (bool)v.type : "The value was empty"
|
||||||
@require v.type.kindof == ENUM : "Value was not an enum"
|
@require v.type.kindof == ENUM : "Value was not an enum"
|
||||||
*>
|
*>
|
||||||
macro any_to_enum_ordinal(any v, $Type)
|
macro any_to_enum_ordinal(any v, $Type)
|
||||||
@@ -16,6 +17,7 @@ macro any_to_enum_ordinal(any v, $Type)
|
|||||||
|
|
||||||
<*
|
<*
|
||||||
@require $Type.kindof.is_int() : "Type was not an integer"
|
@require $Type.kindof.is_int() : "Type was not an integer"
|
||||||
|
@require (bool)v.type : "The value was empty"
|
||||||
@require v.type.kindof.is_int() : "Value was not an integer"
|
@require v.type.kindof.is_int() : "Value was not an integer"
|
||||||
*>
|
*>
|
||||||
macro any_to_int(any v, $Type)
|
macro any_to_int(any v, $Type)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
- Removed support for LLVM 17, 18.
|
- Removed support for LLVM 17, 18.
|
||||||
|
|
||||||
### Stdlib changes
|
### Stdlib changes
|
||||||
None
|
- Add contract on `any_to_enum_ordinal` and `any_to_int` to improve error when passed an empty any. #2977
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
None
|
None
|
||||||
|
|||||||
Reference in New Issue
Block a user