stan-dev / stan-dev/stanc3

FR: Allow UDFs to vary only in `data` annotations

Open
#1,531 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

typechecker
Dominant language
OCaml
Stars
160
Forks
59
Avg merge
21h 45m
Merged PRs (30d)
26

Description

Currently, defining the same function with the two signatures which are identical except for data annotations does not work (Stan will error during compilation with "Function '[...]' has already been declared for signature [...]`.

This is not usually a big issue, because the data annotations are optional and AFAIK don't provide a substantial benefit - except for allowing you to call other functions which only accept data arguments. Activity analysis (what's data, what's parameter) still happens AFAIK.

However, to work around #3224 , I now sometimes have to add data annotations, and I would like to just do it automatically (via code generation) whenever needed. However, this currently would lead to issues if the same function needs to get called with arguments that have different "activities". The data annotated function would of course not accept the parameter arguments, and defining the same function with more permissive data annotations is currently impossible.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points; begin by locating the compiler validation that rejects UDFs differing only in data annotations. Done means such overloads compile while calls with incompatible argument activities remain correctly rejected, with regression coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.