Skip to main content
Generated from the rslc compiler.

E-QUANTUM

A type name has one precision. A type such as Money = Num {precision: 0.01} gives its name one precision. This check guards a type name that two declarations give two different precisions. A current rater gets an earlier message in its place. The compiler stops at the second declaration of a name with E-UNRESOLVED: duplicate Types declaration 'Money'. A guideline that declares Premium differently from the rater it uses gets E-USE. Keep one declaration for each type name. Give a second precision its own name, such as WholeMoney = Num {precision: 1}.

E-ROUND

A rounding states its scale and mode. round takes three arguments: a value, a scale and a mode. The scale is a whole number of decimal places: 2 for cents, 0 for whole dollars, -1 for tens. The mode is one of half_up, half_down, half_even, up, down, ceiling and floor. Filings differ on how they round a tie, so RSL leaves the mode for you to state. A rounding that states its rule gives the filed premium on every request, including one that lands on half a cent. Example The premium calls round with a value and a scale, and leaves out the mode.
Fix Add the mode the filing states as the third argument. half_up rounds a tie away from zero.
Other causes
  • round has one argument, or more than three.
  • The scale is an increment such as 0.01; write the number of decimal places, 2.
  • The scale lies outside -1000 to 1000.
  • The mode is a name outside the seven modes, such as nearest.
  • round_each: (scale, mode) of a stepwise sum or product breaks one of the scale and mode rules above.
  • interpolate! has result: exact; the result states a scale and a mode, and only ratio: and step: take exact.
  • interpolate! has a negative ratio: scale; a ratio lies between 0 and 1, so its scale is 0 or more.
bad/rater.rsl
good/rater.rsl

E-FOLD-KEY

A stepwise fold names its order. A stepwise fold rounds after every step: product(self.drivers as d by d.number, d.factor, round_each: (3, half_up)). It takes one element at a time and rounds the running result each time. Rounding at every step makes the order of the elements matter. The by key fixes that order, so a request rates the same however it lists its drivers. The check asks for by and round_each together, on a sum or a product. The key is a number or date input of the element, read as d.number. Each element of one list has its own key value, and the rater rejects a request that repeats one. Example The product rounds each step to three decimals and leaves out the by key.
Fix Add by with the input that orders the elements, here the driver number.
Other causes
  • A fold has by and lacks round_each; add the rounding, or delete by for an exact sum or product.
  • by or round_each sits on a fold other than sum and product, such as max, avg or count.
  • The key is a computed value such as d.factor * 2, or an attribute of another record such as self.payroll.
  • round_each sits on a sum of plain values, such as sum(self.payroll, 1, round_each: (3, half_up)); a stepwise fold reads a list.
  • rank has a by key; rank orders by the list’s own keyed by field.
bad/rater.rsl
good/rater.rsl

E-COMPUTED-RANGE

A calculation proves its declared range. A calculation states a promise about its value. A range reads where self in [0, 100000], and a precision comes from a type such as Premium = Num {precision: 0.01}. The compiler works out the range and precision of the body from the inputs it reads. The check asks the body to prove the promise for every request the rater accepts. Calculations that read the value rely on the promise, for example as a divisor or a table key. A promise the body proves holds for every premium the rater returns. Example The premium declares a range up to 100,000. Payroll reaches 100,000,000 at a rate of 2 per 1,000, so the body reaches 200,000.
Fix State the range the body reaches. A filing that caps the premium calls for a clamp: min(round(…), 100000). A filing that limits payroll calls for a narrower range on the input.
Other causes
  • The body reads an input with an open range such as [0, _], so the body has an open bound on that side.
  • The calculation’s type has a precision and the body is off that grid, such as a Premium of whole dollars rounded to cents. Round the body to the declared scale: round(…, 0, half_up).
bad/rater.rsl
good/rater.rsl