Skip to content
Playground(another site)

bynk.context.rebrand_construction

Error A variant of a uses-sourced commons sum type was constructed directly inside a context, where the emitter's per-context rebrand leaves its constructors out of scope.

A context that uses a commons gets its sum types by name, but not their variant constructors, so Circle(1.0) is refused there: the context re-exports the type under its own name, without the constructors. Build the value in the commons, in a function that returns it, and call that function from the context.

Example

geo/shapes.bynk
commons geo.shapes
type Shape = | Circle(radius: Float) | Square(side: Float)
// app/main.bynk
context app.main
uses geo.shapes
fn unit() -> Shape {
Circle(1.0) // ✗ constructors are not in scope here
}
// geo/shapes.bynk
fn unitCircle() -> Shape { Circle(1.0) } // ✓ built in the commons
// app/main.bynk
fn unit() -> Shape {
unitCircle() // ✓ called from the context
}

In the Book

See also

  • Every code in its category, Contexts, on the diagnostic index.
  • bynk explain bynk.context.rebrand_construction shows the same from the installed toolchain, without a network.