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 error message on Filter_Condition missing arguments in Table.filter #7290

Merged
merged 2 commits into from
Jul 14, 2023

Conversation

radeusgd
Copy link
Member

@radeusgd radeusgd commented Jul 13, 2023

Pull Request Description

In #7148 I improved the error message when a Filter_Condition constructor without arguments is provided to Vector.filter and its friends. This PR applies the same check to the Table.filter.

This is useful, because when we select a Filter_Condition from a widget, initially it does not have all its arguments applied. This used to lead to confusing errors being reported to the user, now, a much clearer error is shown:

image

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@radeusgd radeusgd added the CI: No changelog needed Do not require a changelog entry for this PR. label Jul 13, 2023
@radeusgd radeusgd self-assigned this Jul 13, 2023
Comment on lines -455 to +456
filter self column filter=(Filter_Condition.Equal True) on_problems=Report_Warning = case column of
filter self column (filter : Filter_Condition | Function = Filter_Condition.Equal True) on_problems=Report_Warning = case column of
Copy link
Member Author

Choose a reason for hiding this comment

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

This has to be Filter_Condition | Function instead of Filter_Condition|(Any->Boolean) due to #7289

element -> (== element)

## PRIVATE
Checks if the given `function` is actually a `Filter_Condition` constructor
that is just missing arguments. If so, it will report a more friendly error.
Otherwise it will just return the `function` as is.
handle_constructor_missing_arguments function =
Otherwise it will run the `continuation`.
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like something we'll need for other constructors, perhaps it should be made generic.

Copy link
Member

Choose a reason for hiding this comment

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

Agree we may want to make this generic until we can improve type checking. Not one for this PR, but maybe next time we add one.

Copy link
Member Author

Choose a reason for hiding this comment

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

The issue is - we are doing a bit of a heuristic to check if this is really a Filter_Condition - by looking at the text representation.

If we want to make it generic, we'd have to make this more robust as that does not seem like a good 'hack' to spread around.

Anyway, this only applies to situations where we have X | Function types. For types that do not accept a Function (most of our ADT args do not), it will be ideal to have this check done at runtime typecheck level.

element -> (== element)

## PRIVATE
Checks if the given `function` is actually a `Filter_Condition` constructor
that is just missing arguments. If so, it will report a more friendly error.
Otherwise it will just return the `function` as is.
handle_constructor_missing_arguments function =
Otherwise it will run the `continuation`.
Copy link
Member

Choose a reason for hiding this comment

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

Agree we may want to make this generic until we can improve type checking. Not one for this PR, but maybe next time we add one.

@radeusgd radeusgd added the CI: Ready to merge This PR is eligible for automatic merge label Jul 14, 2023
@mergify mergify bot merged commit 866283c into develop Jul 14, 2023
@mergify mergify bot deleted the wip/radeusgd/fix-table-filter-unapplied branch July 14, 2023 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants