Skip to content

Remaining per-page accuracy findings (grammar, generics, and eight stdlib pages) #5

Description

@O6lvl4

Leftovers from the per-page audit — every item below was reproduced by running it. The cross-cutting defects (lambda syntax, function-type notation, pipe placeholder, auto-import classification, operator precedence) are already fixed in a33359f; these are the ones still open.

reference/grammar.md

  • Missing operators from the operator list: >>, !, ?, ??, ?.
  • Missing built-in types: Bytes, Matrix, RawPtr, Never
  • Auto-import list omits error, datetime, int8uint64, float32
  • "next line starts with . (method chaining)" continuation rule — a leading . is a parse error. Leading |> does work.
  • not is listed among the binary operators; it is unary

guide/generics.md

The two bound examples cannot be used as written:

  • fn show[T: Repr](item: T)Repr is not auto-derived for a bound. Calling it gives type 'Point' does not implement protocol 'Repr', and built-in types like Int can never satisfy it.
  • fn compare[T: Ord](a: T, b: T) -> Bool = a < b — declares fine but is uncallable; Int does not implement Ord, and a user type declared : Ord fails in codegen.

The only bounds built-in types actually satisfy are Numeric and Hash. Suggest rewriting both examples against a user-defined protocol (the Serializable shape in protocols.md, which does work).

stdlib pages

  • json: get is described as fetching a nested value — it is flat top-level only. get_int / as_int are described as returning none for a non-integer — they truncate floats (2.7some(2)). to_map missing from the function table. JsonPath cannot be written as a type annotation.
  • bytes: set is described as mutating in place — it returns a new Bytes and leaves the original alone even for a var binding (the in-place one is the undocumented set_at). push really takes mut b: Bytes, so it needs a var. The is_empty([]) example does not compile. The whole current surface (read_uint16/32, read_int32, read_float32, write_*, set_*, Endian) is undocumented.
  • list: pop is described as discarding the last element — it returns it. The filter_map example passes int.parse, which returns Result, not Option. list.is_empty([]) needs an annotated empty list.
  • map: map.new() needs a type annotation to compile as shown.
  • string: slice is documented 3-arg; the third parameter has a default, so the 2-arg form works and is undocumented.
  • option / result: option.is_none(none), result.is_err(err(…)) and result.to_err_option(err(…)) all fail to build (filed upstream as almide#899). error.context's error type is fixed to String, not generic as documented, and its example uses result as a variable name, which is a module.
  • datetime / matrix: the reference examples contradict their own setup values (a timestamp fixed at 12:00:00 whose minute is documented as 30; a matrix that is 3×4 in one example and 2×2 in the next).
  • testing: omits the built-in assert, assert_eq, assert_ne (no import needed) — the most-used assertions. assert_some / assert_ok are generic natively; the Option[String] / Result[String, String] restriction the page states is the WASM-only one, and assert_throws has no WASM implementation at all.

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