Skip to content

sum-types: Error more eagerly when a definition's name shadows an enum/newtype constructor #1606

@RyanGlScott

Description

@RyanGlScott

Surprisingly, Cryptol accepts this program on the sum-types branch (#1602):

newtype T a = { unT : a }

T = ()

It probably shouldn't. Cryptol will error if you actually try to use T anywhere, but Cryptol arguably should error as soon as you try to load the file.

Cryptol does eagerly error if you load this program using Cryptol 3.0.0 or the master branch:

$ ~/Software/cryptol-3.0.0/bin/cryptol Foo.cry 
┏━╸┏━┓╻ ╻┏━┓╺┳╸┏━┓╻  
┃  ┣┳┛┗┳┛┣━┛ ┃ ┃ ┃┃  
┗━╸╹┗╸ ╹ ╹   ╹ ┗━┛┗━╸
version 3.0.0
https://cryptol.net  :? for help

Loading module Cryptol
Loading module Main
[error]
    Overlapping symbols defined:
    (at Foo.cry:1:9--1:12, Main::T)
    (at Foo.cry:3:1--3:2, Main::T)
Loading module Cryptol

This suggests that there is an issue on the sum-types branch specifically.

The same issue also applies if T is an enum constructor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething not working correctlyenumsIssues related to enums

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions