Comments (4)
@lattner can you please take a look?
from mojo.
I just saw that he provided an answer to my Discord question that I asked a few weeks ago (link - https://discord.com/channels/1087530497313357884/1190784717998538903/1196704091041185843).
As soon as new version of Mojo will be released I will check if this bug got fixed or not.
Thank you for your work.
from mojo.
yes, there is a bug here. We are doing the right thing non-trivial types, but trivial types like pointer are not handled correctly. This should be a compile time error:
fn main():
var array = Pointer[Int]()
_ = array^ ## Consumes the array variable
_ = array[2] ## Should be invalid to use "array" because it is consumed (would also crash at runtime in this case)
from mojo.
Ah, actually not. The real issue is that the transfer operation on a value of trivial type (like a pointer or integer) is actually a noop. It doesn't destroy the input value, because these things don't have copy constructors, move operators or the other stuff to track.
Thank you for filing this, this is pretty confusing. I filed the compiler to generate a warning to make this more clear:
x.mojo:4:14: warning: transfer from a value of trivial register type 'Pointer[Int, 0]' has no effect and can be removed
takePtr(array^)
^
from mojo.
Related Issues (20)
- [BUG][LSP]: LSP can't track PythonObject usage
- [BUG]: Import in unreachable if block causes crash
- [BUG]: len(汉) returns 3 instead of 1 like in Python HOT 2
- [BUG]: Implicit conversion from `FloatLiteral` to simd vector with integer dtypes should be disallowed
- [Modular CLI]: M2 Mac air , fail to install new mojo even afeter clean modular/old mojo. Encounter modular: error: Error extracting /: Can't remove already-existing dir HOT 12
- [BUG]: mojo crash: Assertion `!failed && "we know this should always work because we lexed it"' failed. HOT 1
- [BUG]: Can't iterate over `DynamicVector` passed in as parameter HOT 2
- [BUG]: `[]` notation of `Dictionary` doesn't pick the right overload
- [BUG]: mojo crash: assertion failed in Casting.h:566 HOT 1
- [BUG]: Compiler crashes while analyzing function signature after variadic arguments
- [BUG]: Empty strings concat raises `(os/kern) failure (5)` sometimes(!) HOT 1
- [BUG]: Parser crashes binding Reference to lvalue with subtype lifetime HOT 3
- [BUG]: Wrong error produced for borrowed argument
- [Feature Request] Make AnyRegType EqualityComparable
- [BUG]: Debugger does not stop at breakpoint in VSC on Github codespace HOT 2
- [BUG]: mojo crash: Assertion `outermostFuncScope && "couldn't find an enclosing function"' failed.
- [BUG]: mojo crash: Assertion `argIdx != 0 && "TODO: unexpected self mismatch"' failed. HOT 2
- [BUG]: mojo crashes while parsing the `0 and Float32`
- Mojo SDK post-install test failure on Ubuntu 24.04
- [Modular CLI]: Installation of Mojo fails (fedora-39) HOT 2
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 mojo.