Skip to content

Subtraction being translated as abs(a - b), consider more adequate translation #304

Description

@machulen

Sample:

pragma solidity ^0.5.0;

contract C {
 function f() public {
  uint8 a = 2;
  uint8 b = 5;
  uint8 c = a - b;
 }
}

Translated:

type state is unit;

function f (const res__unit : unit) : (unit) is
  block {
    const a : nat = 2n;
    const b : nat = 5n;
    const c : nat = abs(a - b);
  } with (unit);

This preserves the type (nat) but produces wrong value 3, whereas in Solidity it would be 253

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions