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

IsNil panics when passing in an untyped nil value #412

Open
kevinkassimo opened this issue Oct 23, 2023 · 1 comment
Open

IsNil panics when passing in an untyped nil value #412

kevinkassimo opened this issue Oct 23, 2023 · 1 comment

Comments

@kevinkassimo
Copy link

Describe the bug
When calling GRuleEnvironment.ExecuteRule(...) with knowledge base that contains a null field and a rule that calls IsNil on this field, it prints that it panics. The recovered error message after stepping through the error shows reflect: Call using zero Value argument

To Reproduce
Steps to reproduce the behavior:

  1. Create a DataContext and call dataCtx.AddJSON("f", someJSON) where this JSON is { "nullable": null }
  2. Create a rule that says IsNil(f.nullable).
  3. Pass the rule and the knowledge based based on this data context and call ExecuteRule.

Seems that this happens during CallFunction which reflect will check for the inherent type of the value. Since nil by itself is untyped, it fails the the above error.

Expected behavior
IsNil should evaluate to true.

Additional context
Add any other context about the problem here.

@efeertugrul
Copy link

Same issue happened to me today. I have used the nil literal as NIL in IsNil function by typing IsNil(NIL) just for test purposes, also the Fact.STH = NIL; line also raised panic for the same reason.

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

2 participants