-
Notifications
You must be signed in to change notification settings - Fork 323
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
Meta.get_constructor_fields works for Type #5869
Conversation
...ain/java/org/enso/interpreter/node/expression/builtin/meta/GetConstructorFieldNamesNode.java
Outdated
Show resolved
Hide resolved
Why do we want to treat Type as an Atom? Why not introduce a Meta.Type? I think it could be quite useful to distinguish Atom instances from their Types. They really are different things in the language and the merging of them looks artificial. |
Only one [FAILED test after bd9916e? In such case we can consider implementing
I guess we should fix the error first, and then start design work on the new |
bd9916e
to
0a6ac0a
Compare
Test.specify "fields of a Type" <| | ||
typ = Boolean | ||
|
||
Meta.is_atom typ . should_be_true | ||
meta_typ = Meta.meta typ | ||
meta_typ . should_be_a Meta.Atom | ||
fields = case meta_typ of | ||
Meta.Atom.Value _ -> meta_typ.constructor.fields | ||
_ -> Test.fail "Should be a Meta.Atom.Value: " + meta_typ.to_text | ||
|
||
fields . should_equal [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add a test where typ
is not a regular type but a module, like Meta
?
As mentioned, this also used to fail on modules and I'd like to ensure it doesn't crash there too.
Looks like the fix should apply there just fine, but good to have a test to avoid regressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback applies to Module
as well: https://github.com/enso-org/enso/pull/5869/files#diff-63d4533fccf2dfeb8e87e9ccba516458b86d82dd6f4ee9d9a4b7cc6dec4e667bR35 - too late to do changes to the #5869 PR, but feel free to add a test in its own PR.
Pull Request Description
Fixes #5805 by returning
[]
as list of fields ofType
.Important Notes
Type
is recognized asMeta.is_atom
since #3671. HoweverType
isn't anAtom
internally. We have to provide special handling for it where needed.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Java,
style guides. In case you are using a language not listed above, follow the Rust style guide.