Comments (6)
Thanks. Yes, please do; I'll merge.
from ivory.
OK, I have two solutions. One is a quick fix that does an explicit zero check for the for
and times
functions. This has the downside that it adds a conditional every time these functions are used. I'm also not sure if you allow zero length arrays, but if you do then it could be a problem there as well.
The other solution that I've implemented is a more thorough solution that adds parameters for whether or not to be inclusive with the end value to the LoopIncr constructors. This change required a fair amount of modification, and broke a couple of tests that I haven't had a chance to look into further.
Let me know which you'd prefer.
from ivory.
Can you post the more thorough solution? It is likely close to what we've been considering--- @jameysharp discovered an issue a while ago we still haven't fixed in which (0 :: Ix 1) passed to for
results in a bug. We might as well fix this once and for all. Don't worry about breaking old tests.
from ivory.
OK, I've created a pull request.
I believe the issue existed for for
and times
, and should be fixed for both.
Also, thanks for the talk on Wednesday, it was swell.
from ivory.
In case anyone wonders, discussion of this issue continued over on pull request #30.
from ivory.
OK, I've implemented a few changes as of 9d2d186 to deal with this:
- The
loop
function inIvory.Language.Loop
now takesIxRep
arguments for the bounds of the loop instead ofIx n
, allowing for the indexes to be computed before the call toloop
for
andtimes
now useloop
directly, instead of viaupTo
ordownTo
for
andtimes
compute the loop bounds atIxRep
instead ofIx n
, which avoids the underflow in the case thatn
is0
Additionally, I've made loop
no longer exported from the Ivory.Language.Loop
module, and similarly cleaned up the export list for Ivory.Language.Ix
.
The downside to this fix is that if you do give an argument of type Ix 0
to times
, you'll likely introduce either garbage data, or divide-by-zero. The fix for this is to always use the div-zero
pass when generating code, which should catch cases like that.
from ivory.
Related Issues (20)
- Invalid code generated: initialization discards βconstβ qualifier from pointer target type HOT 9
- Hackage build failed HOT 4
- The documentation for the latest version of this package is missing on Hackage. HOT 2
- Question: Using "Simple" Sum Types in Ivory HOT 2
- Why `deref` is effectful? HOT 7
- Add support for template-haskell-2.12 HOT 1
- Constant assertions
- Remove `IvoryZero` constraint from `ifte` and `cond`
- Travis entry for 7.10 looks invalid
- http://ivorylang.org seems down HOT 1
- How to actually run the tutorial? HOT 1
- ivory-backend-acl2 can not work
- Incompatibility with newer versions of base-compat and monadLib HOT 1
- The documentation for the latest version of `ivory-backend-c` is missing on Hackage. HOT 3
- ProcPtrs and Refs in MemAreas
- Remove noop casts in the C code HOT 4
- Finish/integrate new model-checker
- Generalize Ivory memory model
- Ivory module system improvements
- cvc4 errors in local test HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ivory.