Git Product home page Git Product logo

Comments (5)

mvdan avatar mvdan commented on May 3, 2024

This also seems to work:

var elem u8 = arr[in.a >> 6]

from wuffs.

mvdan avatar mvdan commented on May 3, 2024

I see now that I am supposed to be explicit about ranges when declaring vars:

var b u8[..0x3] = in.a >> 6
var elem u8 = arr[b]

If that's what I should be doing, then please do close this issue. Though I would argue that this should be in an FAQ somewhere; I assumed that Wuffs automatically did this.

from wuffs.

nigeltao avatar nigeltao commented on May 3, 2024

Yeah, that will work for now, but longer term, you probably shouldn't need the [..0x3] range refinement. Currently, after an assignment like x = y, we automatically add the fact x == y. In the future, we might also add facts x >= min_possible_y and x <= max_possible_y, although specifying exactly how to calculate the min and max values, especially if y is an expression, could be tricky. In your case, after b = in.a >> 6, that should implicitly assert that b <= 3, and so the array index arr[b] is proved in bounds, without needing the [..0x3].

But, yeah, in the very short term, adding [..0x3] will keep you moving.

from wuffs.

mvdan avatar mvdan commented on May 3, 2024

Awesome, thanks. Should this issue stay open then? I no longer have a blocking issue in the short term, but it would still be nice if this worked automatically.

from wuffs.

nigeltao avatar nigeltao commented on May 3, 2024

Let's keep the issue open for now.

from wuffs.

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.