Skip to content

Strange behavior with where clauses in module signatures #121

@mb64

Description

@mb64

Scope: I'm not sure whether this is an issue with SOSML or SOSML-frontend. Both behave strangely, but in different ways.

Description / To Reproduce:

Given this (valid) code (SOSML editor link):

signature SIG = sig type ty end;

structure Mod :> SIG where type ty = int = struct
  type ty = int
end;

val x: Mod.ty = 4;

The SOSML CLI ignores everything after the declaration of SIG:

SOSML> Welcome to SOSML. Please enter your code.

Input> signature SIG = sig type ty end;
SOSML> signature SIG: sig
     >    type ty;
     >  end;
Evaluation took 3ms.

Input> structure Mod :> SIG where type ty = int = struct
Input>   type ty = int
Input> end;
Input> val x: Mod.ty = 4;
Input> ;
Input> hello?
SOSML> There was a problem with your code:
     > Parsing failed: Expected a declaration, found "hello".

On the other hand, the SOSML editor accepts the module definition, but rejects the last line with the error

Elaboration failed: The annotated type "Mod.ty" does not match the expression's type "int": Cannot merge "int" and "Mod.ty".

Additionally, after making a simple change and then undoing it, it stops accepting the declaration of Mod, at which point every small edit (adding or deleting whitespace, for example) makes it reinterpret ty as ty → int, eventually resulting the error looking like this:

Elaboration failed: Signature mismatch: Wrong implementation of type "ty": Cannot merge "((((((((((((((((((int → int) → int) → int) → int) → int) → int) → int) → int) → int) → int) → int) → int) → int) → int) → int) → int) → int) → int) → int" and "int".

Metadata

Metadata

Assignees

No one assigned

    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