Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support selective field import for types. #3145

Open
Tracked by #3921
q-uint opened this issue Mar 8, 2022 · 1 comment
Open
Tracked by #3921

Support selective field import for types. #3145

q-uint opened this issue Mar 8, 2022 · 1 comment
Labels
Bug Something isn't working language design Requires design work P3 low priority, resolve when there is time typing Involves the type system

Comments

@q-uint
Copy link

q-uint commented Mar 8, 2022

Module A

// moduleA.mo
module {
    public type Workday = {#mon; #tue; #wed; #thu; #fri};
    public type Weekday = Workday or {#sat; #sun};
};

Module B

// moduleB.mo
import { Weekday } = "moduleA";

let x : Weekday = #sat;

Error

moduleB.mo:1.10-1.17: type error [M0119], object field Weekday is not contained in expected type
  module {}

Solution (but not desired)

import A "moduleA";

let x : A.Weekday = #sat;
@ggreif
Copy link
Contributor

ggreif commented Mar 8, 2022

Correct. Selective import of types from modules is not supported yet (see #3076). We don't even have a syntax for it, so you'll have to stick to the workaround you are applying above.

We don't have an ETA for when this will be fixed.

My hunch is that it will look like

import { type Weekday } = "moduleA";

when done. Thanks for the report!

@ggreif ggreif added Bug Something isn't working language design Requires design work P3 low priority, resolve when there is time typing Involves the type system labels Mar 8, 2022
@crusso crusso mentioned this issue Apr 4, 2023
79 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working language design Requires design work P3 low priority, resolve when there is time typing Involves the type system
Projects
None yet
Development

No branches or pull requests

2 participants