Commit 6d634fc
committed
Resolve the user header through one shared precedence rule
The header precedence lived in a four-branch chain inside compile() and
was insufficient in two ways. cpp_options may already have been
repopulated from precompile_cpp_options_ by the time it ran, so an
explicit user_header = NULL still selected an inherited USER_HEADER; and
cmdstan_model(compile = FALSE) never enters compile() at all, so
constructing a model with an explicit NULL alongside a cpp_options header
silently kept the header and built with it.
The precedence is now a small pure resolver called from both
initialize() and compile(). An explicit non-NULL argument wins; an
explicit NULL clears both cpp_options spellings; only an omitted argument
consults cpp_options and then the stored header. Supplied-ness is
captured before anything is reassigned, since user_header = NULL is also
the default and cannot otherwise be told from an omitted argument -- with
missing() in compile() and, for arguments arriving through ..., with
names(), which list(...) preserves for NULL entries. Warnings are emitted
at the call sites so a model compiled at construction warns once rather
than twice. Both spellings are reduced to the one actually used, so
$cpp_options() no longer reports the ignored duplicate.
A header changing identity now forces compilation, through a dirty flag
rather than by inferring it from cpp_options_: a compile through the
lowercase spelling never leaves USER_HEADER behind, stored options are
WSL-safe paths while user_header is deliberately a host path, and an
absent entry conflates "no header" with "unknown". The flag is latched
rather than assigned, because on a bare retry after a failed compile the
reuse branch resolves back to the same header and nothing looks changed.
It is cleared only by a successful executable replacement.
user_header_ and using_user_header_ are configuration for the next
invocation rather than a description of the executable, so they are
assigned as soon as they are validated. A failed compile with a new
header is usually a bug in that header, and a bare retry after fixing it
must build the header the user supplied. This also stops a failed
compile from leaving using_user_header_ FALSE, which made
$check_syntax() report the bogus "declared without specifying a
definition" error again. Shape is validated wherever a header is
accepted, so character(0) is rejected informatively, while existence is
checked only when compiling, keeping a header created between
construction and $compile() working.1 parent 5f04a7d commit 6d634fc
3 files changed
Lines changed: 361 additions & 69 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
147 | 221 | | |
148 | 222 | | |
149 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
247 | 251 | | |
248 | 252 | | |
249 | 253 | | |
| |||
263 | 267 | | |
264 | 268 | | |
265 | 269 | | |
266 | | - | |
267 | 270 | | |
268 | | - | |
269 | | - | |
270 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
271 | 284 | | |
272 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
273 | 290 | | |
274 | 291 | | |
275 | 292 | | |
| |||
584 | 601 | | |
585 | 602 | | |
586 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
587 | 609 | | |
588 | 610 | | |
589 | 611 | | |
| |||
617 | 639 | | |
618 | 640 | | |
619 | 641 | | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
639 | 647 | | |
640 | 648 | | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
645 | 654 | | |
646 | 655 | | |
647 | 656 | | |
648 | 657 | | |
649 | | - | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
650 | 662 | | |
651 | 663 | | |
652 | 664 | | |
| 665 | + | |
653 | 666 | | |
654 | 667 | | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
655 | 680 | | |
656 | 681 | | |
657 | 682 | | |
| |||
662 | 687 | | |
663 | 688 | | |
664 | 689 | | |
| 690 | + | |
665 | 691 | | |
666 | 692 | | |
667 | 693 | | |
668 | 694 | | |
669 | 695 | | |
670 | 696 | | |
| 697 | + | |
| 698 | + | |
671 | 699 | | |
672 | 700 | | |
673 | 701 | | |
| |||
831 | 859 | | |
832 | 860 | | |
833 | 861 | | |
834 | | - | |
835 | | - | |
| 862 | + | |
836 | 863 | | |
837 | 864 | | |
838 | 865 | | |
| |||
0 commit comments