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

WIP: Adds warning on comparing same FirstNameNode #2312

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jas-valgotar
Copy link
Contributor

@jas-valgotar jas-valgotar commented Apr 9, 2024

This pull request introduces a warning when comparing two identical FirstNameNode instances, which could be either global or scoped variables.
This enhancement is particularly beneficial in scenarios involving scoped variables, where it's easy to misunderstand the concept of implicit ThisRecord.

It's important to note that this change is non-breaking, as it only adds a warning without generating an error.

@LucGenetier
Copy link
Contributor

✅ No public API change.

return false;
}

private static bool IsNoOPFirstNameComparison(TexlNode left, TexlNode right)
Copy link
Contributor

@MikeStall MikeStall Apr 9, 2024

Choose a reason for hiding this comment

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

IsNoOPFirstNameComparison

this is key change... #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NOTE: I will check the impact of the change with the PowerApps using a private build.

MikeStall
MikeStall previously approved these changes Apr 9, 2024
Copy link
Contributor

@MikeStall MikeStall left a comment

Choose a reason for hiding this comment

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

:shipit:

// Helps warn no op comparison, e.g. Filter(table, ThisRecord.Value = Value)) or Filter(table, Value = Value)
if (IsNoOPFirstNameComparison(node))
{
_txb.ErrorContainer.EnsureError(DocumentErrorSeverity.Severe, node, TexlStrings.WrnNoOpFieldComparison);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be a warning instead of DocumentErrorSeverity.Severe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are absolutely right! Thanks for catching it...

@jas-valgotar jas-valgotar changed the title Adds warning on comparing same FirstNameNode WIP: Adds warning on comparing same FirstNameNode Apr 11, 2024
@LucGenetier
Copy link
Contributor

✅ No public API change.

@LucGenetier
Copy link
Contributor

✅ No public API change.

@@ -4575,4 +4575,8 @@
<value>Delegation warning. The result of this argument '{0}' may be truncated for large data sets before being passed to the '{1}' function.</value>
<comment>Error message when an argument to non-delegable function has possible delegation and resulting rows may be truncated</comment>
</data>
<data name="WrnNoOpFieldComparison" xml:space="preserve">
<value>This comparison will always be constant. (Always yields true or false). Please consider using 'As' keyword for aliasing scoped variable if this not what you want.</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

aliasing isn't a super low-code friendly term. run this by a PM or content person?

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.

None yet

5 participants