Skip to content

feat(server): add builtin function typechecking + BuiltinFn enum#149

Open
Khanathan wants to merge 7 commits into
beava-dev:mainfrom
Khanathan:feat/issue-56-builtin-typechecking
Open

feat(server): add builtin function typechecking + BuiltinFn enum#149
Khanathan wants to merge 7 commits into
beava-dev:mainfrom
Khanathan:feat/issue-56-builtin-typechecking

Conversation

@Khanathan
Copy link
Copy Markdown

@Khanathan Khanathan commented May 21, 2026

Summary

First step of RFC-001: Pythonic expressions. Converts BuiltinFn from a
static struct table to a closed Rust enum, promotes cast to its own
Expr::Cast AST node, and switches Expr::Call to carry the resolved
BuiltinFn instead of a String. Adds shared type-inference primitives +
helpers for later components. No IR or Python change.

Linked issues

Linked to #56

Implementation Plan

  • Add tests for all components that will be implemented in this PR
  • Move expr_builtins.rsbuiltins/mod.rs; update 5 importers. Old built-in tests still pass
  • Add InferError and TypeClass.
  • Add 4 reusable typechecking primitives + 8 shared helpers. All tests for those pass
  • BuiltinFn enum (variants: IsNull, QuadkeyCast excluded) + 5 match self methods + Display + name↔variant round-trip. Replaces old struct, BUILTINS slice, and lookup_builtin
  • quadkey_infer (the one builtin without a shared helper). Project builds cleanly
  • Refactor Expr::Call.fn_name: StringExpr::Call.builtin: BuiltinFn; parser resolves names at parse time and emits ExprParseError::UnknownBuiltin
  • Promote cast to Expr::Cast { operand, target, span }; add arms in span, referenced_fields, to_expr_string, eval_depth, infer_expr_type_inner
  • Runs all tests and style checks. Everything passes, no warnings

Verification:

All three Rust gates passed:

  • fmt: 25s
  • clippy: 324s
  • test: 587s

Pre-flight checklist

  • bash .github/scripts/check.sh exits 0 (or each step passes manually)
  • Verification block above replaced with real output

@Khanathan Khanathan marked this pull request as ready for review May 21, 2026 01:02
@Khanathan Khanathan requested a review from petrpan26 as a code owner May 21, 2026 01:02
@Khanathan Khanathan changed the title feat(server): add builtin function typechecking feat(server): add builtin function typechecking + BuiltinFn enum May 23, 2026
Khanathan and others added 7 commits June 1, 2026 15:10
…ser, normalizer, evaluator, added Expr::Cast variant
Rename unify_var0_strict -> infer_same_type, unary_*/binary_* helpers to
str_to_str/numeric_to_f64/two_numeric_to_f64/infer_same_type_all_args, and
drop the redundant unify_var0_with_class helper (callers compose
require_arg_class + infer_same_type instead).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wire is_cast_legal into the Expr::Cast inference path so e.g. cast(bytes, int)
is rejected at register time, matching the column-level apply_cast_schema path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PR-2 base declared the NFS/SMB/CIFS/FUSE super-magic constants as u64,
but libc's statfs.f_type is i64 on this platform, so the matches! arm
failed to compile. Matches the i64 declaration already used elsewhere.
@Khanathan Khanathan force-pushed the feat/issue-56-builtin-typechecking branch from 58c52b2 to e834104 Compare June 1, 2026 22:29
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