Skip to content

Move non-core built-ins into standard library modules - #32

Merged
S42yt merged 2 commits into
masterfrom
feat/std-builtins
Oct 7, 2026
Merged

S42yt merged 2 commits into
masterfrom
feat/std-builtins

Conversation

@S42yt

@S42yt S42yt commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

What

The basics stay built in and need no import:

  • printing and reading input
  • conversions and typeOf
  • the operations on strings, arrays and maps (len, .push, .split, .trim, …)
  • the wrapping number operations

Everything else now belongs to the standard library module it fits:

Module Functions
std/math sqrt pow abs floor ceil round min max sin cos tan asin acos atan atan2 log log10 exp
std/random random randomInt seed
std/time now nowMs millis clock sleep
std/json parseJSON toJSON
std/fs readFile writeFile appendFile fileExists
std/process env args exit panic
std/testing assert
std/strings isLetter isDigit isAlphanumeric isWhitespace

They stay fast built-ins at runtime; only their visibility depends on the import.

How

  • Checker: a moved function used without its module imported gets `sqrt` is in the standard library module `std/math`.
    • The error carries a certain fix that adds import "std/math" after the last import, or at the top.
    • It is reported once per module per file, and dry checking passes don't report it.
  • Exceptions: standard library modules themselves, burn eval and the REPL keep everything without imports.
  • Migrating code: burn fix adds all missing imports at once.
  • Language server: moved functions complete with an auto-import edit when their module isn't imported, and hovers, completions and signature help say "Needs import "std/math"".
  • burn doc: builtin pages show an Import tag.
  • burn init: the library template's test imports std/testing for assert.

Migration in this repository

burn fix added the imports to:

  • the examples
  • tests/cases
  • the library tests
  • the module tests
  • burnfmt

The only diffs are added imports. tests/cases/numbers.out changes only by the shifted line numbers.

The docs are updated too:

  • docs/stdlib/builtins.mdx has a new "In the standard library" section with the table.
  • The five doc and README examples that used moved functions now have their imports.
  • std/math and std/fs docs no longer say these need no import.

Tests

  • New error fixture: tests/errors/std_import.
  • The burn fix fixture now also adds import "std/math" (8 fixes).
  • fmt, clippy and the full suite pass.
  • The CI toolchain smoke test passes locally: package build, burnfmt --check, examples, and burn init + burn build.

Merge burnlang/ash#6 first. ash uses some of these functions; its migration adds the imports and also works with the current Burn.

🤖 Generated with Claude Code


Generated by Claude Code

The basics stay importless: printing, conversions and the operations on
strings, arrays and maps. Math functions now need std/math, random numbers
std/random, clocks and sleep std/time, parseJSON and toJSON std/json, file
functions std/fs, env, args, exit and panic std/process, assert std/testing,
and the character classes std/strings. A missing import is reported once per
module with a fix that adds it, so burn fix migrates code; burn eval and the
REPL keep everything. The language server completes these functions with an
auto-import and shows their module in hovers, and burn doc lists it.
@S42yt
S42yt merged commit 5577593 into master Oct 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant