GithubHelp home page GithubHelp logo

Comments (4)

jondgoodwin avatar jondgoodwin commented on May 20, 2024

This is surely a stupid bug that I can hopefully fix without much effort. Appreciate you letting me know.

from cone.

jondgoodwin avatar jondgoodwin commented on May 20, 2024

Update: this turns out to be a rather gnarly bug,. It may be stupid, but it is not easy to diagnose or fix.

First off, the error message is deceptive. The real bug is not an initialization error during data flow analysis.

The real error actually lives in the type checking pass. a += 1 has special handling as an "opassign" operator, where the left hand is treated as an lval.

  • The first attempt lowers it to i32::+=(&mut a, 1).
  • Since i32 does not have a '+=' method, it gets lowered again to a block like this: {imm temp = &mut a; *temp = *temp + 1}.

That lowering is sometimes not working correctly and getting abbreviated to only the second statement in the block. This abbreviation means that data flow analysis never notices temp being initialized (since it does not see temp getting declared with an initial value). And thus we get the error.

The opassign lowering logic in fncall is a safety hazard. I need to refactor it to work in a more inclusive straightforward way. This will take more effort and experimentation to get right. Still on my queue to finish up....

from cone.

jondgoodwin avatar jondgoodwin commented on May 20, 2024

The opassign logic has been refactored to be easier to follow and safer.

It turns out several other bugs were also in play:

  • A generation bug on intrinsic handling of double floats
  • Bad logic in block type checking that pretended to inject a blockret, but didn't, causing block to misplace the lowered last expression (<-- the real reason for the reported bug)

All bugs have been fixed. Please close if you confirm this issue is now solved.

from cone.

Ivo-Balbaert avatar Ivo-Balbaert commented on May 20, 2024

Great, it works!

from cone.

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.