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

Functions defined with defn- can be referenced from other namespaces #750

Open
smeghead opened this issue Aug 17, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@smeghead
Copy link
Member

Q A
Phel version 0.15.1
PHP version 8.2.22

Summary

Functions defined with defn- can be referenced from other namespaces.

https://phel-lang.org/documentation/api/#defn-1

(defn- name & fdecl)
Define a private function that will not be exported.

I think the specification is that functions defined with defn- cannot be referenced from another namespace.

Current behavior

Functions defined by defn- in another namespace are available for reference.

How to reproduce

  • src/other.phel
(ns defn-access\other)

(def public-value "this is public value.")

(def- private-value "this is private value. THIS MUST BE INVISIBLE.")

(defn public-function []
  "this is public function.")

(defn- private-function []
  "this is private function. THIS MUST BE INVISIBLE.")
  • src/main.phel
(ns defn-access\main
  (:require defn-access\other))

(println other/public-value)
(println other/private-value)

(println (other/public-function))
(println (other/private-function))
$ vendor/bin/phel run src/main.phel 
this is public value.
this is private value. THIS MUST BE INVISIBLE.
this is public function.
this is private function. THIS MUST BE INVISIBLE.

You will see that variables and functions defined with def- and defn- in another namespace are available for reference.

Expected behavior

I would expect an error to occur when referencing a variable or function defined with def- or defn- in a different namespace.

@smeghead smeghead added the bug Something isn't working label Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant