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

Improve where clause unmet error #1883

Closed
JJ opened this issue May 30, 2018 · 8 comments
Closed

Improve where clause unmet error #1883

JJ opened this issue May 30, 2018 · 8 comments

Comments

@JJ
Copy link
Collaborator

JJ commented May 30, 2018

The Problem

When the constraint in a where clause is not met, it says expected anonymous constraint to be met

Expected Behavior

It would be better if there was some way of fleshing out anonymous constraint by printing the signature or the actual anonymous constraint. Or some way of making the constraints not anonymous and print the actual name of the constraint.

Environment

This is perl 6 2018.05

@zoffixznet
Copy link
Contributor

print the actual name of the constraint

What would that look like? In the vast majority of cases it'd be a Callable without a name (hence the "anonymous") and they'd all just have a ;; $_? is raw as signature, making printing that detrimental rather than useful.

@lizmat
Copy link
Contributor

lizmat commented May 30, 2018 via email

@zoffixznet
Copy link
Contributor

zoffixznet commented May 30, 2018

Perhaps we should store the code of the constraint as a string somewhere as well, something akin “use trace” does but then very locally?

I'm a bit worried about this type of errors one day ending up in some public error log. Same as value-printing errors can reveal credit card numbers, the code-dumping errors can reveal important pieces of the program. And would very long Callables be abridged or dumped as is, flooding the screen with code?

Also, wouldn't already-high memory use be even higher if we store the code itself together with all the anonymous Callables?

The user is in full control of what error shows up on typecheck. There's even a Subset::Helper module if you need to do it a lot. This feels a lot like the now-reverted "awesome" error for .parse-base that was bending over backwards to give marginally better error and ended up creating half a dozen bugs.

@JJ
Copy link
Collaborator Author

JJ commented May 30, 2018 via email

@0racle
Copy link
Contributor

0racle commented Jul 15, 2022

This is an old issue, but I think the goal is worthy, so I wanted to open up discussion.

I suspect providing the constraint code in current implementation may not be easy as the "text" of the constrain is simply not available, but perhaps RakuAST with it's support for deparsing may make that easier?

Alternatively, could subset syntax be extended to take an additional (optional) field containing a String describing the constraint (which then gets printed in the exception if it's there)?

Thoughts?

@FCO
Copy link
Member

FCO commented Jul 15, 2022

@0racle isnt that kind of the intent of will complain?

@vrurg
Copy link
Member

vrurg commented Jul 15, 2022

@0racle isnt that kind of the intent of will complain?

It is. I'm closing this issue as resolved.

@vrurg vrurg closed this as completed Jul 15, 2022
@vrurg
Copy link
Member

vrurg commented Jul 15, 2022

@0racle thanks for unearthing this one! :)

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

No branches or pull requests

6 participants