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

disallow user-defined function overloading #1547

Closed
bob-carpenter opened this issue Jul 16, 2015 · 4 comments
Closed

disallow user-defined function overloading #1547

bob-carpenter opened this issue Jul 16, 2015 · 4 comments
Assignees
Milestone

Comments

@bob-carpenter
Copy link
Contributor

Danny Goldstein reported on stan-users that the following problem parses and code generates, but doesn't compile.

functions {

  real add_mul(int a, int b){
    return a + b * a + b;
  }

  vector add_mul(vector a, vector b){
    return a + b .* a + b;
  }

}

data {
  int N;
  vector[N] y;
  vector[N] x;
}

parameters {
  real sigma;
  real m;
  real b;
}

model {
  vector[N] f;
  f <- m * x + b;
  y ~ normal(f, sigma);
}

This produces the following error on the develop branch of cmdstan and stan:

--- Linking C++ model ---
clang++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan/src -isystem stan/lib/stan_math_2.7.0 -isystem stan/lib/eigen_3.2.4 -isystem stan/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -Wno-unused-function -Wno-tautological-compare -Wno-c++11-long-long -ftemplate-depth=256    -O0 -o /Users/carp/temp2/dg src/cmdstan/main.cpp -include /Users/carp/temp2/dg.hpp 
In file included from <built-in>:326:
In file included from <command line>:5:
/Users/carp/temp2/dg.hpp:71:8: error: redefinition of 'add_mul_functor__'
struct add_mul_functor__ {
       ^
/Users/carp/temp2/dg.hpp:41:8: note: previous definition is here
struct add_mul_functor__ {
       ^
1 error generated.

Either we need to figure out how to allow overloading, or have stanc catch the redeclaration and return an error.

@bgoodri
Copy link
Contributor

bgoodri commented Jul 17, 2015

I am continuing to think that appending the argument types to the C++ class name would work around this relatively easily
https://groups.google.com/d/msg/stan-users/arKMsfesJp0/ld_KVwj2YNUJ

@andreeleuterio
Copy link

Hi folks,
I have PyStan installed on a Linux environment with no internet connection, so I installed it from source.
I try running the basic Eight Schools example and keep getting the following output:
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_95013624776d537c3cd7cd4d641c30e0 NOW. Traceback (most recent call last): File "eightschools.py", line 33, in <module> iter=1000, chains=4) File "/home/workgroups/reit/apps/python/2.7.7/pystan/2.9.0.0/lib/python2.7/site-packages/pystan/api.py", line 368, in stan verbose=verbose) File "/home/workgroups/reit/apps/python/2.7.7/pystan/2.9.0.0/lib/python2.7/site-packages/pystan/model.py", line 312, in __init__ build_extension.run() File "/apps/python/2.7.7/lib/python2.7/distutils/command/build_ext.py", line 337, in run self.build_extensions() File "/apps/python/2.7.7/lib/python2.7/distutils/command/build_ext.py", line 446, in build_extensions self.build_extension(ext) File "/apps/python/2.7.7/lib/python2.7/distutils/command/build_ext.py", line 496, in build_extension depends=ext.depends) File "/apps/python/2.7.7/lib/python2.7/distutils/ccompiler.py", line 574, in compile self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) File "/apps/python/2.7.7/lib/python2.7/distutils/unixccompiler.py", line 122, in _compile raise CompileError, msg distutils.errors.CompileError: command 'gcc' failed with exit status 1

I have the latest version of Pystan, with Stan 2.9.0. Also, I have RStan installed on the same environment and the same example runs fine.

Thank you in advance

@ariddell
Copy link
Contributor

@aeleuterio would you mind opening an issue at the pystan repository? https://github.com/stan-dev/pystan/issues When you open an issue, please let us know what Linux distribution you're using and what version of gcc if you know it.

@andreeleuterio
Copy link

@ariddell Will do, I apologize for posting on the wrong forum

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

No branches or pull requests

4 participants