Giter VIP home page Giter VIP logo

Comments (3)

anderseknert avatar anderseknert commented on August 24, 2024

Some further digging, and I've removed the "some .. in" constraint from the description as that wasn't required.

package p

import rego.v1

nums[x] contains x if some x in [1, 2, 3]

bug if {
    n1 := 1
    nums[n1]
}
❯ opa eval -f pretty -d p.rego data.p
1 error occurred: p.rego:9: rego_type_error: undefined ref: data.p.nums[n1]
	data.p.nums[n1]
	            ^
	            have (type): number
	            want (one of): [__local2__]

Using a numeric literal instead of a variable works:

not_bug if {
    nums[1]
}

It seems to only happen for numeric keys, as the same policy works when using string keys:

package p

import rego.v1

nums[x] contains x if some x in ["1", "2", "3"]

bug if {
    n1 := "1"
    nums[n1]
}

from opa.

stale avatar stale commented on August 24, 2024

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.

from opa.

anderseknert avatar anderseknert commented on August 24, 2024

Bumped into this again in Regal. This time, it's at least clear that the type checker mistakenly expects strings as keys, even though numbers are clearly used. Simplified example:

package p

import rego.v1

nums[x] contains x if some x in [1, 2, 3]

bug if {
    nums[x]
    x == 1
}
1 error occurred: policy.rego:9: rego_type_error: match error
	left  : string
	right : number

Quite annoying :/

from opa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.