mirror of
https://github.com/enso-org/enso.git
synced 2024-11-22 11:52:59 +03:00
Fixing small bugs uncovered by type checker (#11422)
Once our libraries and tests are compiled with basic inference of method types, some warnings were reported: ``` X:\NBO\enso\built-distribution\enso-engine-0.0.0-dev-windows-amd64\enso-0.0.0-dev\lib\Standard\Database\0.0.0-dev\src\DB_Column.enso:1003:19: warning: Calling member method `div` on type Number will result in a No_Such_Method error in runtime. 1003 | halfway = scale.div 2 | ^~~~~~~~~~~ X:\NBO\enso\built-distribution\enso-engine-0.0.0-dev-windows-amd64\enso-0.0.0-dev\lib\Standard\Image\0.0.0-dev\src\Matrix.enso:381:21: warning: Invoking a value that has a non-function type (type Image) will result in a Not_Invokable error in runtime. 381 | to_image self = Image (Image.from_vector self.normalize.to_vector self.rows self.channels) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ X:\NBO\enso\built-distribution\enso-engine-0.0.0-dev-windows-amd64\enso-0.0.0-dev\lib\Standard\Table\0.0.0-dev\src\Internal\Multi_Value_Key.enso:94:22: warning: Calling static method `new` on (type Illegal_State) will result in a No_Such_Method error in runtime. 94 | Error.throw (Illegal_State.new "Ordered_Multi_Value_Key is not intended for usage in unordered collections.") | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` This PR attempts to fix them. There was also an expected error in the Examples: ``` X:\NBO\enso\built-distribution\enso-engine-0.0.0-dev-windows-amd64\enso-0.0.0-dev\lib\Standard\Examples\0.0.0-dev\src\Main.enso:139:36: warning: Calling static method `frobnicate` on (type No_Methods) will result in a No_Such_Method error in runtime. 139 | no_such_method = Panic.recover Any No_Methods.frobnicate . catch | ^~~~~~~~~~~~~~~~~~~~~ ``` To avoid getting a warning, I wrapped this in `(_ : Any)` to make the warning go away. The behaviour of the function is unchanged.
This commit is contained in:
parent
fdab2233ac
commit
cf5326fbd1
@ -999,7 +999,10 @@ type DB_Column
|
||||
round_integer : Integer -> Boolean -> DB_Column
|
||||
round_integer self decimal_places use_bankers =
|
||||
new_name = self.naming_helper.function_name "round" [self]
|
||||
scale = 10 ^ -decimal_places
|
||||
Runtime.assert (decimal_places <= 0)
|
||||
## We assert that the decimal_places is non-positive, so the scale will be an Integer.
|
||||
We can tell that to the type-checker by adding an annotation.
|
||||
scale = (10 ^ -decimal_places) : Integer
|
||||
halfway = scale.div 2
|
||||
remainder = self % scale
|
||||
remainder.let "remainer" remainder->
|
||||
|
@ -136,7 +136,11 @@ type No_Methods
|
||||
|
||||
## Returns a no_such_method_error as a value.
|
||||
no_such_method : No_Such_Method
|
||||
no_such_method = Panic.recover Any No_Methods.frobnicate . catch
|
||||
no_such_method =
|
||||
## We expect a No_Such_Method error here, so we annotate the type with `Any`
|
||||
to avoid getting the warning from the static type checker.
|
||||
no_methods_as_any = No_Methods : Any
|
||||
Panic.recover Any no_methods_as_any.frobnicate . catch
|
||||
|
||||
## A simple error type for example purposes.
|
||||
type My_Error
|
||||
|
@ -378,7 +378,7 @@ type Matrix
|
||||
|
||||
example_to_image = Examples.matrix.to_image
|
||||
to_image : Image
|
||||
to_image self = Image (Image.from_vector self.normalize.to_vector self.rows self.channels)
|
||||
to_image self = Image.from_vector self.normalize.to_vector self.rows self.channels
|
||||
|
||||
## GROUP Standard.Base.Conversions
|
||||
ICON convert
|
||||
|
@ -91,7 +91,7 @@ type Ordered_Multi_Value_Key_Comparator
|
||||
## PRIVATE
|
||||
hash x =
|
||||
_ = [x]
|
||||
Error.throw (Illegal_State.new "Ordered_Multi_Value_Key is not intended for usage in unordered collections.")
|
||||
Error.throw (Illegal_State.Value "Ordered_Multi_Value_Key is not intended for usage in unordered collections.")
|
||||
|
||||
## PRIVATE
|
||||
Comparable.from (that:Ordered_Multi_Value_Key) = Comparable.new that Ordered_Multi_Value_Key_Comparator
|
||||
|
@ -123,4 +123,3 @@ main filter=Nothing =
|
||||
suite = Test.build suite_builder->
|
||||
add_specs suite_builder
|
||||
suite.run_with_filter filter
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user