WhileyCompiler icon indicating copy to clipboard operation
WhileyCompiler copied to clipboard

Exposing Private Declarations

Open DavePearce opened this issue 5 years ago • 0 comments

There is currently a problem with a type such as the following:

public type ExposedSquare is {
    bool holdsBomb,
    int rank
} where rank >= 0 && rank <= 8

public type HiddenSquare is {
    bool holdsBomb,
    bool flagged
}

public type Square is ExposedSquare | HiddenSquare

This incorrect reported the following:

./src/model.whiley:26: exposing private declaration
public type Square is ExposedSquare | HiddenSquare
                      ^^^^^^^^^^^^^
./src/model.whiley:26: exposing private declaration
public type Square is ExposedSquare | HiddenSquare
                                      ^^^^^^^^^^^^

This was confusing at first. In fact, the problem was the functions of the same name were not marked public. For example:

export function ExposedSquare(uint rank, bool bomb) -> ExposedSquare
requires rank <= 8:
    return { rank: rank, holdsBomb: bomb }

DavePearce avatar Dec 09 '19 01:12 DavePearce