Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.

Weird error when trying to create custom exception #230

Open
Lupus opened this issue Nov 28, 2019 · 2 comments
Open

Weird error when trying to create custom exception #230

Lupus opened this issue Nov 28, 2019 · 2 comments
Labels
bug Resolve Issues relating to the resolver Yet Another Module System Issues/PRs relating to YAMS

Comments

@Lupus
Copy link

Lupus commented Nov 28, 2019

I'm following code in 'exception.ml' and try to create my own exception, but run into an error. This is relevant part of my source file:

open import "prelude.ml"

type decode_error = Decode_error of string
deriving instance typeable decode_error

instance Exception.exception decode_error begin
  let describe_exception (Decode_error x) = "Decode error: " ^ x
end

Amc complains:

error (E1001)
  Variable not in scope: `describe_exception`

  Arising from use of the binding
    │ 
126 │   let describe_exception (Decode_error x) = "Decode error: " ^ x
    │       ^^^^^^^^^^^^^^^^^^

The following message has a detailed explanation: 1001.
Try 'amc explain 1001' to see it.

I'm not sure what's exactly wrong here.

@SquidDev SquidDev added the bug label Nov 28, 2019
@SquidDev
Copy link
Member

SquidDev commented Nov 28, 2019

Instances should bring their methods into scope within the instance body, but apparently we overlooked that. Sorry!

A temporary workaround would be placing open Exception somewhere before your definition.

@Lupus
Copy link
Author

Lupus commented Nov 28, 2019

Yeah, I already worked around exactly the way you suggest :)

@SquidDev SquidDev added Resolve Issues relating to the resolver Yet Another Module System Issues/PRs relating to YAMS labels Nov 28, 2019
SquidDev added a commit that referenced this issue Feb 27, 2021
Fixes the error in #291. This isn't a pefect solution (would be nice
to do this in resolve and cover #230 too), but it'll do for now.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Resolve Issues relating to the resolver Yet Another Module System Issues/PRs relating to YAMS
Projects
None yet
Development

No branches or pull requests

2 participants