fixed anonymous label casing
This commit is contained in:
parent
87e723649e
commit
c96b1c2faf
1 changed files with 12 additions and 9 deletions
|
|
@ -473,15 +473,12 @@ export function repl({
|
||||||
|
|
||||||
const labels = meta.labels || [];
|
const labels = meta.labels || [];
|
||||||
|
|
||||||
|
// Check for anonymous labels (labels starting with '$')
|
||||||
|
const hasAnonymousLabel = labels.some((label) => label.name.startsWith('$'));
|
||||||
|
|
||||||
// Store code blocks in dictionary using labels as keys
|
// Store code blocks in dictionary using labels as keys
|
||||||
if (labels.length > 0) {
|
if (hasAnonymousLabel) {
|
||||||
for (let i = 0; i < labels.length; i++) {
|
// variable/function declarations that don't return patterns are allowed,
|
||||||
// processing transpiler output instead of code is simply to avoid
|
|
||||||
// extra regex in detecting whether or not an inline widget has been commented out
|
|
||||||
processLabeledBlock(labels, i, meta.output, options, meta);
|
|
||||||
}
|
|
||||||
} else if (pattern !== silence) {
|
|
||||||
// variable/function declarations that return silence are allowed,
|
|
||||||
// but anonymous pattern blocks pose an issue for block-based evaluation
|
// but anonymous pattern blocks pose an issue for block-based evaluation
|
||||||
// if an anonymous pattern is evaluated multiple times it will just stack and get louder and louder
|
// if an anonymous pattern is evaluated multiple times it will just stack and get louder and louder
|
||||||
|
|
||||||
|
|
@ -490,11 +487,17 @@ export function repl({
|
||||||
// otherwise we'll have no idea of which pattern is being overridden
|
// otherwise we'll have no idea of which pattern is being overridden
|
||||||
|
|
||||||
// (we probably need to update the docs on this)
|
// (we probably need to update the docs on this)
|
||||||
|
|
||||||
// we could easily enable it, but it would confuse a lot of people
|
// we could easily enable it, but it would confuse a lot of people
|
||||||
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'anonymous labels disabled for block based evaluation (see https://strudel.cc/blog/#label-notation)',
|
'anonymous labels disabled for block based evaluation (see https://strudel.cc/blog/#label-notation)',
|
||||||
);
|
);
|
||||||
|
} else if (labels.length > 0) {
|
||||||
|
for (let i = 0; i < labels.length; i++) {
|
||||||
|
// processing transpiler output instead of code is simply to avoid
|
||||||
|
// extra regex in detecting whether or not an inline widget has been commented out
|
||||||
|
processLabeledBlock(labels, i, meta.output, options, meta);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Declaration block (variable/function that returns silence)
|
// Declaration block (variable/function that returns silence)
|
||||||
// Store it so its miniLocations are preserved for highlighting patterns stored in variables
|
// Store it so its miniLocations are preserved for highlighting patterns stored in variables
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue