Skip to content

Calling count function with a falsy where filter causes a runtime check error #57

@bob-pasabi

Description

@bob-pasabi

When I try to run a count with a by and where clause and the where clause evaluates to false the code produces an error message from the runtime checks.

Contrived example

LET Ip := input();
LET ACondition := false;
LET TotalCount := count(BY Ip WHERE ACondition TOTAL);

Expected behavior

Should complete without issue and not add 1 to the count.

Actual behavior

Sqrl script runs fine but an error is printed out to the output

CodedError during sqrl execution:: arg error calling _bumpCount
arg 1: expected array

Steps to reproduce the behavior

Save the example and run

sqrl run test.sqrl -s 'Ip="1.2.3.6"' TotalCount

This appears to be caused by https://github.com/sqrl-lang/sqrl/blob/main/packages/sqrl-redis-functions/src/CountFunctions.ts#L260 which is expecting an array as the argument and null is getting passed during a false statement.

Not sure if I am doing something wrong with my setup or use, it's the first day I've tried to evaluate the library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions