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

[superseded] Add optional recursive argument to typetraits.distinctBase #18654

Closed
wants to merge 3 commits into from

Conversation

ALANVF
Copy link
Contributor

@ALANVF ALANVF commented Aug 7, 2021

Should be self-explanatory.

Example code:

import typetraits

type
    A = distinct int
    B = distinct A

echo B.distinctBase        #=> int
echo B.distinctBase(false) #=> A

This theoretically shouldn't break anything because recursive is true by default

lib/pure/typetraits.nim Show resolved Hide resolved
Comment on lines 193 to 197
let rec =
if traitCall.len >= 2:
operand2.intVal != 0
else:
true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the best way to do this? Can't this read the static bool directly somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that it is (also see my last change, replaced operand2 with traitCall[2])

Copy link
Member

@timotheecour timotheecour Aug 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is incorrect, and fails; see correct way here: #18659

@timotheecour
Copy link
Member

see #18659

@Araq Araq closed this Aug 9, 2021
@timotheecour timotheecour changed the title Add optional recursive argument to typetraits.distinctBase [superseded] Add optional recursive argument to typetraits.distinctBase Aug 9, 2021
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 this pull request may close these issues.

4 participants