mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
return type errors in places previously missed
This commit is contained in:
parent
0944c8e715
commit
a3ac776907
1 changed files with 13 additions and 8 deletions
|
@ -19,7 +19,7 @@ func set_value(new_value: Variant) -> void:
|
|||
|
||||
|
||||
## Virtual function. Used to convert [param other] to the overriding class' type.
|
||||
static func from(other: DeckType):
|
||||
static func from(other: DeckType) -> DeckType:
|
||||
return null
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ class DeckTypeNumeric extends DeckType:
|
|||
## [code]0.0[/code] for [code]false[/code].[br]
|
||||
## In the case of [DeckType.DeckTypeString], converts to String if it is a valid number
|
||||
## or [DeckType.DeckTypeError] otherwise.
|
||||
static func from(other: DeckType):
|
||||
static func from(other: DeckType) -> DeckType:
|
||||
if other is DeckTypeNumeric:
|
||||
return other
|
||||
|
||||
|
@ -74,7 +74,7 @@ class DeckTypeNumeric extends DeckType:
|
|||
return inst
|
||||
|
||||
var err: DeckTypeError = DeckTypeError.from(other)
|
||||
err.error_message = "Conversion to Numeric is only possible from String or Bool."
|
||||
err.error_message = "Conversion to Numeric is only possible from String or Bool"
|
||||
return err
|
||||
|
||||
|
||||
|
@ -84,12 +84,13 @@ class DeckTypeString extends DeckType:
|
|||
_value = value
|
||||
|
||||
|
||||
static func from(other: DeckType):
|
||||
static func from(other: DeckType) -> DeckTypeString:
|
||||
if other is DeckTypeString:
|
||||
return other
|
||||
|
||||
var inst := DeckTypeString.new()
|
||||
inst._value = var_to_str(other.get_value())
|
||||
return inst
|
||||
|
||||
|
||||
## Boolean type. Corresponds to the JSON bool type.
|
||||
|
@ -103,7 +104,7 @@ class DeckTypeBool extends DeckType:
|
|||
## if the value is a zero value ([code]0.0[/code] and [code]-0.0[/code]), [code]true[/code] otherwise.[br]
|
||||
## In the case of [DeckType.DeckTypeDictionary] or [DeckType.DeckTypeArray],
|
||||
## the resulting value will be [code]true[/code] if the container is not empty.
|
||||
static func from(other: DeckType):
|
||||
static func from(other: DeckType) -> DeckType:
|
||||
if other is DeckTypeBool:
|
||||
return other
|
||||
|
||||
|
@ -117,6 +118,10 @@ class DeckTypeBool extends DeckType:
|
|||
inst._value = !other.get_value().is_empty()
|
||||
return inst
|
||||
|
||||
var err := DeckTypeError.from(other)
|
||||
err.error_message = "Cannot create a DeckTypeBool from non-numeric or non-container type"
|
||||
return err
|
||||
|
||||
|
||||
## Array type. Corresponds to the JSON Array type.
|
||||
class DeckTypeArray extends DeckType:
|
||||
|
@ -126,14 +131,14 @@ class DeckTypeArray extends DeckType:
|
|||
|
||||
## Arrays can only be converted from a string in the format
|
||||
## [code]"["foo", 2, "bar"][/code].
|
||||
static func from(other: DeckType):
|
||||
static func from(other: DeckType) -> DeckType:
|
||||
if other is DeckTypeString:
|
||||
var inst := DeckTypeArray.new()
|
||||
inst._value = str_to_var(other.get_value())
|
||||
return inst
|
||||
|
||||
var err: DeckTypeError = DeckTypeError.from(other)
|
||||
err.error_message = "conversions to Array is only possible from String"
|
||||
err.error_message = "Conversions to Array is only possible from String"
|
||||
return err
|
||||
|
||||
|
||||
|
@ -145,7 +150,7 @@ class DeckTypeDictionary extends DeckType:
|
|||
|
||||
## Dictionaries can only be converted from a string in the format
|
||||
## [code]{"key": "value"}[/code].
|
||||
static func from(other: DeckType):
|
||||
static func from(other: DeckType) -> DeckType:
|
||||
if other is DeckTypeString:
|
||||
var inst := DeckTypeDictionary.new()
|
||||
inst._value = str_to_var(other.get_value())
|
||||
|
|
Loading…
Reference in a new issue