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

Selective Field Import #3121

Closed
q-uint opened this issue Feb 23, 2022 · 4 comments · Fixed by #3123
Closed

Selective Field Import #3121

q-uint opened this issue Feb 23, 2022 · 4 comments · Fixed by #3123

Comments

@q-uint
Copy link

q-uint commented Feb 23, 2022

It seems you can not import a file that uses selective field imports.


src
├── X.mo
└── Y.mo
// X.mo
import { Array_init = init } = "mo:⛔";
// Y.mo
import X "X";

Error

src/X.mo:1.8-1.29: type error [M0015], only trivial patterns allowed in static expressions

Context

$(vessel bin)/moc --check $(vessel sources) src/Y.mo
  • vessel 0.6.2
  • Motoko compiler 0.6.21 (source wahvzdqw-grg3wqkh-0n8s7fj6-f4rxx0rh)
@nomeata
Copy link
Collaborator

nomeata commented Feb 23, 2022

Thanks for reporting! This needs
updates in https://github.com/dfinity/motoko/blob/master/src/mo_frontend/static.ml to allow more kinds of patterns.

I wonder if we need to be careful to not accept cyclic definitions, or if the definedness check prevents that. But it's too late today to think this through.

@nomeata
Copy link
Collaborator

nomeata commented Feb 23, 2022

Also, we shouldn't allow anything in libraries that cannot be compiled strategically, i.e. is const in the sense of https://github.com/dfinity/motoko/blob/master/src/ir_passes/const.ml. that handles object patterns already, so we should be good here. (This is important also so that function calls into libraries will be compiled to direct calls to known functions.)

ggreif added a commit that referenced this issue Feb 24, 2022
@ggreif
Copy link
Contributor

ggreif commented Feb 24, 2022

We already permit TupP in that context, can't see how allowing ObjP would be different. Working on a fix.

mergify bot pushed a commit that referenced this issue Feb 24, 2022
@mergify mergify bot closed this as completed in 220d362 Feb 24, 2022
@ggreif ggreif mentioned this issue Feb 24, 2022
@ggreif
Copy link
Contributor

ggreif commented Feb 24, 2022

Released as https://github.com/dfinity/motoko/releases/tag/0.6.22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants