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

Issue with duplicated use of variable named e (or other name shadowing nullary functions) #1060

Closed
rok-cesnovar opened this issue Nov 26, 2021 · 4 comments · Fixed by #1061
Closed
Assignees

Comments

@rok-cesnovar
Copy link
Member

There are a few issues with duplicated use of e variable name.

transformed data {
    vector[3] e;
    vector[3] e;
}

compiles to C++ (it should not), and then fails with the C++ compiler (as expected).

parameters {
    vector[3] e;
    vector[3] e;
}

is an exception in stanc3:

Uncaught exception:
  
  ("Map.of_alist_exn: duplicate key" e)

Raised at Base__Error.raise in file "src/error.ml" (inlined), line 8, characters 14-30
Called from Base__Map.Tree0.Of_foldable.of_foldable_exn in file "src/map.ml", line 1266, characters 8-143
Called from Base__Map.Using_comparator.of_alist_exn in file "src/map.ml", line 2242, characters 25-63
Called from Core_kernel__Map.Creators.of_alist_exn in file "src/map.ml" (inlined), line 236, characters 27-74
Called from Stan_math_backend__Transform_Mir.add_reads in file "src/stan_math_backend/Transform_Mir.ml", line 302, characters 18-46
Called from Stan_math_backend__Transform_Mir.trans_prog in file "src/stan_math_backend/Transform_Mir.ml", line 543, characters 6-69
Called from Dune__exe__Stanc.use_file in file "src/stanc/stanc.ml", line 236, characters 8-38
Called from Dune__exe__Stanc in file "src/stanc/stanc.ml", line 283, characters 9-16

For completeness:

transformed parameters {
    vector[3] e;
}

and

transformed data {
    vector[3] e;
}

work fine.

@rok-cesnovar rok-cesnovar changed the title Issue with variable named e Issue with duplicated use of variable named e Nov 26, 2021
@WardBrian
Copy link
Member

I’m guessing this is related to #1011? Does the same thing happen with the name pi for example?

@rok-cesnovar
Copy link
Member Author

rok-cesnovar commented Nov 26, 2021

Yep, so I would guess all nullary functions are affected.

I should also add that both work fine (semantic error in stanc3) with the stanc3 in the 2.28.1 release (which is the same as the one for 2.28.2).

@WardBrian WardBrian self-assigned this Nov 26, 2021
@WardBrian
Copy link
Member

WardBrian commented Nov 26, 2021

I will take a look next week. It’s probably just an issue of orders of the checks

@rok-cesnovar
Copy link
Member Author

Yeah, no rush. Happy thanksgiving break Brian! :)

@rok-cesnovar rok-cesnovar changed the title Issue with duplicated use of variable named e Issue with duplicated use of variable named e (or other name shadowing nullary functions) Nov 26, 2021
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 a pull request may close this issue.

2 participants