Skip to content

Instantiating a parameterized module results in incorrect operator precedence #1799

@RyanGlScott

Description

@RyanGlScott

Consider the following parameterized module (B) and instantiation of it (Y):

module B where

parameter
  type a: #

type w = 2 ^^ a
type b = 2 ^^ w
module Y = B where
type a = 0

b should be equivalent to 2 ^^ 2 ^^ 0 which, due to (^^) being right-associative, should be equal to 2 ^^ (2 ^^ 0), i.e., 2. Despite this, b is actually equal to 1, not 2:

Y> :m Y
Loading module Cryptol
Loading module `where` argument of Y
Loading interface module `parameter` interface of B
Loading module B
Loading module Y
Y> `b : Integer
1

Compare this to the output of a variant that does not use parameterized module:

module Z where
type a = 0
type w = 2 ^^ a
type b = 2 ^^ w
Z> :m Z
Loading module Cryptol
Loading module Z
Z> `b : Integer
2

Most likely, the parameterized version is incorrectly using the precedence (2 ^^ 2) ^^ 0, which would explain why it computes 1 instead of 2.

Metadata

Metadata

Assignees

Labels

bugSomething not working correctlyparameterized modulesRelated to Cryptol's parameterized modules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions