Skip to content

pair as a keyword cannot be used in all contexts #438

@axic

Description

@axic
contract TupleRet {
  constructor() {}

  function pair() -> (uint256, uint256) {
    return (uint256(7), uint256(11));
  }
}

This fails compilation:

Types: uint256 -> uint256 -> (uint256, uint256) and (uint256, uint256) do not unify
 - in:function pair () -> (uint256, uint256) {
   return pair(uint256.uint256(7), uint256.uint256(11));
}

However pair can be used in other contexts, see test/examples/cases/synonym-in-function.solc:

// Synonyms in function parameter and return types
type Int = word;
type Point = pair(Int, Int);

function add(a: Int, b: Int) -> Int {
    return a;
}
function makePoint(x: Int, y: Int) -> Point {
    return pair(x, y);
}
function getX(p: Point) -> Int {
    match p {
        | pair(x, _) => return x;
    }
}
function getY(p: Point) -> Int {
    match p {
        | pair(_, y) => return y;
    }
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type
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