Partial matching of parameters is confusing

Aperta
#7,393 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@cderv ci sta già lavorando.

Dal 31/10/2023.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug engines-knitr

In Quarto 1.4.451, create the following dashboard with parameters:

---
title: "Sample dashboard"
format: dashboard
engine: knitr
params:
  hello: 1
  mello: "a character"
---

This should print out the value of `params$hello`: `{r} params$hello`.

This should print out the value of `params$mello`: `{r} params$mello`.

This shouldn't work because it's looking for a parameter that doesn't exist, `params$jello`: `{r} params$jello`.

This also shouldn't work because it's looking for a parameter that doesn't exist, `params$m`, but it does partial matching to `params$mello`, and the document renders: `{r} params$m`

It works, but I think it would be better if partial matching wasn't enabled by default for parameters.

Screenshot 2023-10-29 at 2 44 29 AM

Then add the following and re-render:

This doesn't work because it's doing partial matching and then failing when adding a number to a character `params$m + 2`: `{r} params$m + 2`.

You get the following error:

Quitting from lines 2-18 (untitled.qmd)
Error in `params$m + 2`:
! non-numeric argument to binary operator
Backtrace:
 1. .QuartoInlineRender(params$m + 2)
                                                                                          
Execution halted

It makes sense why this happens, but again, not doing partial matching by default would be less confusing.

Additionally, if I set partial matching to warn in the YAML of my document, e.g.,

knitr:
    opts_chunk:
      R.options:
        warnPartialMatchDollar: true

the first example with partial matching still runs, which was even more surprising to me.

Lingua principale
JavaScript
Stelle
6k
Fork
458
Merge medio
1g 9h
PR unite (30g)
41

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di quarto-dev/quarto-cli

Tutte le issue di quarto-dev/quarto-cli

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.