Skip to content
Playground(another site)

bynk.http.cookie_untyped_has_field

Warning An untyped Cookie literal is named like a field of a cookie record of the unit (a warning).

Cookie { name: "theme", value: "Dark" } is a cookie in no record, but here the record Prefs reads that cookie by that name, so the name and the value are written twice with nothing relating them: a renamed field or a changed type leaves the write valid and wrong. It is a warning. Write it from the record, Prefs.theme.cookie(Dark), which is named by the field's wire name and valued as its decoder reads it; keep the attributes by spreading it into a Cookie literal. Where the literal is only a name and a value that provably decodes, the quick-fix does the rewrite.

Example

Ok("x").withCookie(Cookie { name: "theme", value: "Dark" }) // ⚠ `Prefs` reads this cookie
Ok("x").withCookie(Prefs.theme.cookie(Dark)) // ✓

In the Book

See also

  • The grammar rule it governs: http_handler.
  • Every code in its category, HTTP, on the diagnostic index.
  • bynk explain bynk.http.cookie_untyped_has_field shows the same from the installed toolchain, without a network.