-
Notifications
You must be signed in to change notification settings - Fork 61
Import #2540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Import #2540
Conversation
4738a1f
to
cbe27d0
Compare
@xsebek this is definitely ready for you to try out, if you like. Let me know if you have questions, and definitely let me know all the horrible bugs you find. 😄 |
I tried to test it on the move tutorial: - name: 1P wall
system: true
program: |
- def main = \a. pure noop end
instant {
- run "scenarios/Tutorials/move_surveil.sw";
+ import "scenarios/Tutorials/move_surveil.sw" in
main [entity="wall", room=1]
} But the robots fail to run:
Also, could you please fix the cabal run swarm:exe:swarm -- --scenario Tutorials/Move --run <(echo 'move;move') --debug=all |
Ah, sorry, I guess the way I was building it didn't actually end up building every component. And thanks for the bug report! I will take a look. By the way, you can also write a semicolon after the |
@xsebek what did you do to get that crash? When I try it, the system robots in the move tutorial do not work properly, but at least it doesn't crash. But I'm not sure if that's because I'm doing something differently than you, or if I incidentally fixed the crash in the meantime. |
@byorgey the robots still fail to run for me. I used import in Move tutorial thus: Click to expand diffdiff --git a/data/scenarios/Tutorials/move.yaml b/data/scenarios/Tutorials/move.yaml
index 5a20eb6e..ea7f35cc 100644
--- a/data/scenarios/Tutorials/move.yaml
+++ b/data/scenarios/Tutorials/move.yaml
@@ -149,54 +149,44 @@ robots:
- name: 1P wall
system: true
program: |
- def main = \a. pure noop end
instant {
- run "scenarios/Tutorials/move_surveil.sw";
+ import "scenarios/Tutorials/move_surveil.sw" in
main [entity="wall", room=1]
}
- name: 2P wall
system: true
program: |
- def main = \a. noop end
instant {
- run "scenarios/Tutorials/move_surveil.sw";
+ import "scenarios/Tutorials/move_surveil.sw" in
main [entity="wall", room=2]
}
- name: 3P wall
system: true
program: |
- def main = \a. noop end
- instant {
- run "scenarios/Tutorials/move_surveil.sw";
- main [entity="wall", room=3]
- }
+ import "scenarios/Tutorials/move_surveil.sw" in
+ main [entity="wall", room=3]
#################
## GARDENERS ##
#################
- name: 1P flower
system: true
program: |
- def main = \a. noop end
instant {
- run "scenarios/Tutorials/move_surveil.sw";
+ import "scenarios/Tutorials/move_surveil.sw" in
main [entity="flower", room=1]
}
- name: 2P flower
system: true
program: |
- def main = \a. noop end
instant {
- run "scenarios/Tutorials/move_surveil.sw";
+ import "scenarios/Tutorials/move_surveil.sw" in
main [entity="flower", room=2]
}
- name: 3P flower
system: true
program: |
- def main = \a. noop end
- instant {
- run "scenarios/Tutorials/move_surveil.sw";
- main [entity="flower", room=3]
- }
+ import "scenarios/Tutorials/move_surveil.sw" in
+ main [entity="flower", room=3]
entities:
- name: door
display: Then run: cabal run swarm:exe:swarm -- --scenario Tutorials/Move --run <(echo 'move;move') --debug=all --paused After one step, you should see the robots all turn idle in the robot panel. Select any robot to view their log and you should see the "crash". |
84abea8
to
0014960
Compare
@xsebek I think I have now fixed the bug you ran into with the Move tutorial (actually it was two bugs 😄 ). Feel free to poke at this more if you have a chance, I'm sure there are yet more bugs. But it feels like it is slowly converging. Down to only five |
@byorgey great! It seems to take a bit to load, I guess because "Track set of evaluated imports" is not yet done. But after it loads it runs and is responsive. 👍 I can try converting other scenarios with robots to get more test coverage, but the tests do not build now. 🙁
I tried it and it does go into the unexpected branch in step. 🔥
|
Yeah, there's definitely some optimization that still needs to happen. Shouldn't be too hard though.
Hmm, probably just didn't rename something consistently...
Hmm, thanks, I'll look into this more. |
1a6d62f
to
2795204
Compare
2795204
to
ad96a72
Compare
Now that failure stuff has been moved into `swarm-util` as of #2155.
8b5a415
to
8bc4c40
Compare
This PR adds a real, honest-to-goodness
import
construct, towards #495. This PR will not removerun
; I will leave that for a second, follow-up PR.Highlights of this PR:
import "xyz" in ...
syntax which makes definitions fromxyz
available in...
, withimport "xyz"; ...
as shorthandSwarm.Language.Syntax.Import
andSwarm.Language.Load
.SrcLoc
now contains an import location in addition to line/column numbers, to be able to report error locations from recursively processed importsprocessTerm
and friends (inSwarm.Language.Pipeline
) changed quite a bit:IO
, since they may need to go read imports from the filesystem/networkSourceMap
, which is a map from import locations to ASTsRaw
,Resolved
,Inferred
,Typed
,Elaborated
...) and use them to enforce invariants.Swarm.Language.Phase
.Syntax
andTerm
got type annotations, along with pretty much anything that transitively contains them.Swarm.Language.Elaborate
, where we need to useunsafeCoerce
.elaborate
and so on).FromJSON
instances that did everything from parsing through typechecking + elaboration. Now we can't do that sinceparseJSON
can't useIO
, so it can't load and check imports. To ensure we process everything correctly, we now have instances likeFromJSON (Syntax Raw)
and the type parameter ensures that anywhere such an instance was used must be updated to do all the other steps in order to end up with aSyntax Elaborated
.Downsides:
To do:
readValue
processParsedTermNoImports
(and decide what it's really needed for)def
(+ write documentation explaining why)parseCodeFile
to take imports into accountimport
is processed relative to the location of its containing fileSrcLoc
inPrettyPrec LocatedTCFrame
instance