Comments (4)
This is surely a stupid bug that I can hopefully fix without much effort. Appreciate you letting me know.
from cone.
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.
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.
Great, it works!
from cone.
Related Issues (20)
- Compiler reporting of time is sometimes obviously overestimated HOT 2
- Anonymous function output passed to print HOT 1
- Array declaration fails in global scope HOT 1
- Can't access global variable, as if not seen, but in fact it is seen HOT 2
- Doc for `extern` misses (curly braces) xor (colons) HOT 1
- Fails to print u32 HOT 4
- `typedef` fails HOT 6
- Add support for typed array size HOT 1
- Automatic cast of index when using each HOT 1
- Multidim array type compiles but not usable HOT 2
- Problem with multiple return values HOT 4
- Global arrays are not accessible if not initialized HOT 1
- Literals with underscores not recognized by print and returns HOT 3
- + operator called as a method in backticks does not work or is not implemented HOT 1
- Adding elements to a collection with <- doesn't work HOT 1
- Gist creation broken on the playground
- Grammar railroad diagram HOT 5
- SSL certificate on website invalid since Mar 15, 2022 HOT 2
- Unaccounted for line counting when tokenizing strings HOT 1
- Using C from Cone: calling fopen() HOT 1
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 cone.