Comments (11)
This will also reproduce the error on master and also on #235 :
def main()={
var i = 1;
()
}
from effekt.
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.
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.
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.
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.
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.
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.
It is a bit strange since here we say that we need the region:
and here
from effekt.
@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.
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.
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)
- Unhelpful error messages when misusing block arguments
- Initializing List with [] inside a function leads to a Reference Error HOT 2
- Artifact for PLDI 2022 HOT 10
- ML Backend yields different results than JS backend after monomorphization HOT 3
- Multiple copies of a region on the stack HOT 1
- Existential types HOT 2
- Higher-rank polymorphism HOT 3
- Multiple return values
- Interface Polymorphic typing HOT 8
- Handling without control HOT 1
- `--compile` should generate executable HOT 5
- Overloading constructors breaks pattern matching
- Examples of Effect Checking are Out-of-Date
- Private definitions
- Singleton interfaces
- Import and module are implemented counterintuitive HOT 7
- Import everything from a module HOT 1
- Import and namespacing
- SML data / codata representation
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 effekt.