Skip to content

2.0.38 added Event.Text to Base; a program with its own Text constructor is refused with "duplicate declaration: Text", and the notes do not say so #1913

Open

Description

@jonasporto

What you did

bend text_ctor.bend -o text_ctor

What happened

On 2.0.37 the program builds and prints text:hi <p>. On 2.0.38, 2.0.39 and main (bf35ec3, 2026-10-28, run with bun bend2/main.ts) the same file is refused before any of its code is checked:

Error:
- expected : a fresh constructor name (duplicate declaration: Text)
- observed : 'Text'
Location:
4 | type Node is Data:
5>|   Text{s: String}
  |   ^^^^
6 |   Elem{tag: String}

The other declaration is Base's: 2.0.38 gave type Event a Text{text: String} constructor ("Native windows emit Text events", #1019, PR #1441). A constructor name is one namespace with Base, so a Base addition can refuse an existing program that never imports windows. Three things made this cost more than the rename itself:

  1. The 2.0.38 notes mark +RTS, the JS tags and TCP.send as Breaking and say nothing about Text. A new bare constructor name in Base is a breaking change for every program that already uses the name (bend-lint hit the same one: PR fix(lint)!: prefix option constructors to avoid Base collisions #1565).
  2. The error points only at the user's line. It does not say that the other Text is Base's Event.Text, so the first reading is "I declared Text twice", and the search starts in the wrong place.
  3. The guide does not list the bare constructor names Base reserves. Today there are 23 (Chr Close EQ F32 False GT Key LT Look Mouse Move Pix Qua SCon SNil Scroll Succ Text True U32 Unit WNil Zero in 2.0.39's base.bend); Text, Key, Move, Close, Look are ordinary words a DOM, a game or an editor would pick.

What would have avoided the afternoon: a Breaking line in the notes when Base gains a bare constructor name; the error naming the other declaration (Base: Event.Text); and a line in the guide saying Base's constructor names are reserved, with the list or the grep that produces it. Whether a user constructor should be able to shadow Base's, or Base's event constructors should carry a prefix as #1565 did for bend-lint, is your call; the report is about the silence.

The same pattern in 2.0.36: Chan.send answering Result instead of Bool, TCP.recv answering Maybe, and io_eff losing its third argument shipped without a Breaking line (PR #1259). Programs that compiled on 2.0.35 stopped, and for the C effect only clang said so.

The file

import Base

# A program with its own `Text` constructor: 2.0.37 builds it, 2.0.38+ refuses it.
type Node is Data:
  Text{s: String}
  Elem{tag: String}

def show(n: Node) -> String:
  match n:
    case Text{s}:
      "text:" ++ s
    case Elem{tag}:
      "<" ++ tag ++ ">"

def main() -> IO(Unit):
  IO.print(show(Text{"hi"}) ++ " " ++ show(Elem{"p"}))

bend version

bend 2.0.39 (also 2.0.38, and main at bf35ec3 run with bun bend2/main.ts); builds on 2.0.37

uname -sm

Darwin arm64

clang --version (the first line)

Apple clang version 21.0.0 (clang-2100.3.34.2)

Activity

  1. Lorenzobattistela commented on Oct 29, 2026

    @Lorenzobattistela
    Collaborator

    Being handled on #1585

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions