Pular para o conteúdo
TE731 · Tipos · error

`children` de runtime em `<style>` exige `global`

Um `<style children={expr}>` carrega conteúdo de runtime que o compilador não enxerga — não dá para içar nem escopar; escopar texto desconhecido seria mentira. Spec §6.1: conteúdo dinâmico precisa optar por `global` explicitamente (`<style global children={…}>`), a única forma de style que continua sendo nó de render.

Why this fires

A <style> with a children={expr} attribute carries runtime content — the compiler cannot see the CSS text, so it can neither hoist it into the deduplicated stylesheet nor apply the hermetic scope transform. Scoping unknown content would be a lie; the rule (spec §6.1) is that dynamic text must opt into global explicitly.

let css = comptime fs.read("./app.css")

fn page() -> View {
    <div>
        <style children={css}/>
    </div>
}
// error[TE731]: runtime `children` cannot be scoped; write `<style global children={…}>`

Fix it

Add global — the one style form that stays a render node and renders in place:

<style global children={css}/>

The builder spelling accepts the same pair: style(global: true, children: css).

If the content is actually static, write it as a literal body instead — then it hoists and scopes normally:

<style>.card { color: red }</style>

See also

  • TE736<style> outside a component.
  • TE730@() outside a declaration value.

Veja também

Buscar no Zolo

9 resultados

en