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

Code generation can result in functions being included more than once #51

Open
esp1 opened this issue Feb 23, 2023 · 0 comments
Open

Code generation can result in functions being included more than once #51

esp1 opened this issue Feb 23, 2023 · 0 comments

Comments

@esp1
Copy link

esp1 commented Feb 23, 2023

In situations where the same function is referenced in multiple files, ferret code generation can result in the function definitions being included multiple times. In the following example the bar function is called directly in main, and also indirectly via the foo function:

main.clj:

(require 'foo)
(require 'bar)

(foo/foo)
(bar/bar 0)

foo.clj:

(require 'bar)

(defn foo []
  (bar/bar 1))

bar.clj

(defn bar [x]
  x)

If you compile main.clj with ferret, it will emit a .cpp file with multiple definitions of the bar function. Trying to compile that .cpp file will result in these errors:

src/main.cpp:2537:7: error: redefinition of 'class main::bar_bar'
 class bar_bar {
       ^~~~~~~
src/main.cpp:2527:7: note: previous definition of 'class main::bar_bar'
 class bar_bar {
       ^~~~~~~
src/main.cpp:2564:12: error: redefinition of 'ferret::var main::bar_bar::invoke(ferret::ref) const'
 inline var bar_bar::invoke(ref _args_) const {
            ^~~~~~~
src/main.cpp:2551:12: note: 'ferret::var main::bar_bar::invoke(ferret::ref) const' previously defined here
 inline var bar_bar::invoke(ref _args_) const {
            ^~~~~~~
@esp1 esp1 changed the title Code generation can result in functions being include more than once Code generation can result in functions being included more than once Feb 23, 2023
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

No branches or pull requests

1 participant