Git Product home page Git Product logo

Comments (11)

matthias-dunkel avatar matthias-dunkel commented on August 15, 2024 1

This will also reproduce the error on master and also on #235 :

def main()={
 var i = 1;
 ()
}

from effekt.

matthias-dunkel avatar matthias-dunkel commented on August 15, 2024

I do not know why. But changing the work function to this:

def work(cr: Coroutine[String]) = {
    var coroutine = Done();
    coroutine = cr
}

"solves" the bug.

from effekt.

b-studios avatar b-studios commented on August 15, 2024

Looks like a problem where the region for mutable state is inferred incorrectly. Here is the core representation:

def createCoroutine() =
  region { (this) => 
    let tmp476 = Done()
    
    var cr in this = tmp476 ;
    let _ = cr.put(More((box { (s) => 
      Done()
    })));
    let tmp477 = cr.get()
    
    tmp477
  };
def work(cr) =
  val tmp482 = cr();
  var coroutine in this = tmp482 ;
  ();
def main() = work({ () =>  createCoroutine() })

We can see that indeed a region { (this) => ... } is missing around the body of work.

from effekt.

b-studios avatar b-studios commented on August 15, 2024

As a more reasonable workaround, you should be able to provide the region explicitly:

def work{cr: => Coroutine[String]} = region this {
    var coroutine in this = cr();
    ()
}

The bug is related to this function (I guess):
https://github.com/effekt-lang/effekt/blob/master/effekt/shared/src/main/scala/effekt/source/ExplicitRegions.scala#L29

from effekt.

b-studios avatar b-studios commented on August 15, 2024

Eventually in #235 we might solve this bug since we change how local mutable state is represented. @matthias-dunkel could you maybe try to checkout #235 and see what the output is? That would be helpful.

from effekt.

matthias-dunkel avatar matthias-dunkel commented on August 15, 2024

I tried it on #235. It is not working, and here is the output:

function work(cr) {
    const tmp369 = cr;
    
    const coroutine = $this.fresh(tmp369);
    
    return $effekt.pure(cr);
}

from effekt.

b-studios avatar b-studios commented on August 15, 2024

Ha, ok thanks. That solves it ;) Then it is a problem with capture inference. Since you do not use i it is not registered to be required and the region is not introduced.

from effekt.

b-studios avatar b-studios commented on August 15, 2024

It is a bit strange since here we say that we need the region:

https://github.com/effekt-lang/effekt/blob/master/effekt/shared/src/main/scala/effekt/Typer.scala#L702

and here

https://github.com/effekt-lang/effekt/blob/master/effekt/shared/src/main/scala/effekt/source/AnnotateCaptures.scala#L88

from effekt.

b-studios avatar b-studios commented on August 15, 2024

@matthias-dunkel I just tried to reproduce your reported error, but it just works for me on master and on naive-state. Can you help me reproduce it somehow? What are the exact steps I have to take?

from effekt.

matthias-dunkel avatar matthias-dunkel commented on August 15, 2024

As a more reasonable workaround, you should be able to provide the region explicitly:

def work{cr: => Coroutine[String]} = region this {
    var coroutine in this = cr();
    ()
}

The bug is related to this function (I guess): https://github.com/effekt-lang/effekt/blob/master/effekt/shared/src/main/scala/effekt/source/ExplicitRegions.scala#L29

This solved the original issue for me. Is this expected behavior? If yes, I think it should lead to a compiler error and not to a Runtime Error completely unrelated to regions.

from effekt.

b-studios avatar b-studios commented on August 15, 2024

I am closing this issue since it seems to work on master. If you encounter it again, feel free to reopen.

from effekt.

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.