Skip to content

Using modulo with floating points causes panic #1245

Closed
@jaspervdj

Description

Expected Behavior

I would expect that using floating points with the modulo operator is caught somewhere and an error is raised. This is similar to what happens if you e.g. divide by zero:

jasper@kakigori$ opa run
OPA 0.10.5 (commit 8b08af7f, built at 2019-02-25T16:39:16Z)

Run 'help' to see a list of commands.

> 1 / 0
1 / 0: eval_internal_error: div: divide by zero
> 

Actual Behavior

The process panics:

jasper@kakigori$ opa run
OPA 0.10.5 (commit 8b08af7f, built at 2019-02-25T16:39:16Z)

Run 'help' to see a list of commands.

> 1.1 % 1
panic: illegal value

goroutine 1 [running]:
github.com/open-policy-agent/opa/topdown/builtins.NumberToInt(0xc000203850, 0x3, 0xd6e360)
        /go/src/github.com/open-policy-agent/opa/topdown/builtins/builtins.go:163 +0x96
...
main.main()
        /go/src/github.com/open-policy-agent/opa/main.go:12 +0x2d

Steps to Reproduce the Problem

  1. Start opa run
  2. Enter e.g. 1.1 % 1

Additional Info

  • OPA version 0.10.5
  • Linux 4.20.13 on x86_64

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions