Skip to content
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

feat(module): adds cyclic dependecy check #150

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

Samy-33
Copy link
Contributor

@Samy-33 Samy-33 commented Dec 20, 2024

Cyclic dependency check

➜  compiler+runtime git:(optimize/module-system) ✗ cat dev/src/a.jank
(ns a
  (:require [b]))
➜  compiler+runtime git:(optimize/module-system) ✗ cat dev/src/b.jank
(ns b
  (:require [a]))


➜  compiler+runtime git:(optimize/module-system) ✗ ./build/jank --module-path  /home/saket/Documents/oss/jank/compiler+runtime/dev/src repl
Bottom of clojure.core
clojure.core=> (require 'a)
Exception: {:error :assertion-failure, :data {:msg Cyclic load dependency: [ /a ]->/b->[ /a ]}}
clojure.core=> ^D
➜  compiler+runtime git:(optimize/module-system) ✗ nvim dev/src/a.jank
➜  compiler+runtime git:(optimize/module-system) ✗ cat dev/src/a.jank
(ns a)

(require 'b)
➜  compiler+runtime git:(optimize/module-system) ✗ cat dev/src/b.jank
(ns b)

(require 'a)


➜  compiler+runtime git:(optimize/module-system) ✗ ./build/jank --module-path  /home/saket/Documents/oss/jank/compiler+runtime/dev/src repl
Bottom of clojure.core
clojure.core=> (require 'a)
Exception: {:error :assertion-failure, :data {:msg Cyclic load dependency: [ /a ]->/b->[ /a ]}}
clojure.core=> (require 'b)
Exception: {:error :assertion-failure, :data {:msg Cyclic load dependency: [ /b ]->/a->[ /b ]}}

Throws at the top level

➜  compiler+runtime git:(optimize/module-system) ✗ cat dev/src/a.jank
(ns a)

(require 'b)
➜  compiler+runtime git:(optimize/module-system) ✗ cat dev/src/b.jank
(ns b)


(throw "Hello")

➜  compiler+runtime git:(optimize/module-system) ✗ ./build/jank --module-path  /home/saket/Documents/oss/jank/compiler+runtime/dev/src repl
Bottom of clojure.core
clojure.core=> @*loaded-libs*
#{}
clojure.core=> (require 'a)
Exception: Hello
clojure.core=> @*loaded-libs*
#{a b}
clojure.core=>

With ns macro:

➜  compiler+runtime git:(optimize/module-system) ✗ cat dev/src/a.jank
(ns a
  (:require [b]))
➜  compiler+runtime git:(optimize/module-system) ✗ cat dev/src/b.jank
(ns b)

(throw "Hello")
➜  compiler+runtime git:(optimize/module-system) ✗ ./build/jank --module-path  /home/saket/Documents/oss/jank/compiler+runtime/dev/src repl
Bottom of clojure.core
clojure.core=> (require 'a)
Exception: Hello
clojure.core=> @*loaded-libs*
#{b}
clojure.core=>

@jeaye jeaye merged commit bb63f78 into jank-lang:main Dec 20, 2024
2 of 3 checks passed
@jeaye
Copy link
Member

jeaye commented Dec 20, 2024

Love it! 😍

@Samy-33 Samy-33 deleted the optimize/module-system branch December 20, 2024 06:04
@Samy-33
Copy link
Contributor Author

Samy-33 commented Jan 17, 2025

Handles #139: Add cyclical dep check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants