Discarded return values
The complete source of quality_discarded_bad.ek9, which fails to compile exactly as captioned. Shown on quality.html.
Fails with E11050: operator returns a value but result is discarded - assign to variable or use in expression; E11051: pure method/function returns a value but result is discarded - a pure call with no side effects achieves nothing; E11052: method returns Result or Optional but result is discarded - must always be checked
#!ek9 defines module bad.site.quality.discarded defines function calculateTotal() as pure -> items as List of Float <- total as Float: Float(length items) riskyParse() <- rtn <- Result("OK", Integer()) demo() -> price as Float items <- List() of Float price.+(10.0) //Computed value goes nowhere calculateTotal(items) //Pure call achieves nothing riskyParse() //Error silently swallowed
Download quality_discarded_bad.ek9 - it fails to compile on purpose, with the error its @Error line states.