GithubHelp home page GithubHelp logo

Comments (5)

tnowacki avatar tnowacki commented on July 21, 2024 2

No real workaround, if you expanded this to locals instead of temps, you will still get a borrow checker issue.

The minimal repro is

while (cond) {
   let tmp = e;
   let b = &tmp;
   ... use b ...
}

In the borrow checker, first time through the loop:

while (cond) {
   let tmp = e;  // assignment okay
   let b = &tmp; // b = { &tmp }
   ... use b ...
}

Second time through the loop

while (cond) {
   let tmp = e;  // ERROR assignment invalid! 'tmp' is still borrowed by 'b'!
   let b = &tmp; // b = { &tmp }
   ... use b ...
}

The error message just assumed this couldn't happen with a local variable created by the compiler, which happens if you make this example into:

while (cond) {
   let b = &e; 
   ... use b ...
}

You cannot borrow values on the stack in Move, so e gets bound to some local variable. and then the example is equivalent to the first one.

from move.

tnowacki avatar tnowacki commented on July 21, 2024

Ah yes this one again... Should really give a better error message as I don't htink we will fix the underlying issue anytime soon

from move.

wrwg avatar wrwg commented on July 21, 2024

So what is the issue and what is the workaround?

from move.

zekun000 avatar zekun000 commented on July 21, 2024

I think we just need a proper error message instead of ICE for now

from move.

msmouse avatar msmouse commented on July 21, 2024

I think we just need a proper error message instead of ICE for now
And line / column of the issue? (IIUC currently we don't have them)

from move.

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.