Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resolver = "2"
ra_ap_proc_macro_api = { path = "crates/third_party/ra_ap_proc_macro_api" }

[workspace.package]
version = "0.3.0-rc17"
version = "0.3.0-rc18"
description = "The Incan programming language compiler"
edition = "2024"
rust-version = "1.92"
Expand Down
15 changes: 15 additions & 0 deletions crates/incan_core/src/bin/generate_lang_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,21 @@ pub def col(name: str) -> ColumnExpr:

The post-decoration binding keeps the concrete callable signature of the decorated function unless the decorator deliberately returns a different callable shape. Checked API metadata and imports observe that concrete signature, not the generic helper's `F`.

The callable value passed into a decorator exposes `__name__` as the source callable name. Registry and catalog decorators can use this from concrete decorator helpers and from generic `(F) -> F` helpers, so a decorator can record `func.__name__` without requiring the decorated declaration to repeat its own public name in a string argument.

```incan
def capture[F](func: F) -> F:
registry_names.append(func.__name__)
return func

def registered[F]() -> ((F) -> F):
return (func) => capture[F](func)

@registered()
pub def sample(value: int) -> int:
return value + 1
```

Method decorators receive an unbound callable shape with the receiver first. A decorator on `def label(self, value: int) -> str` sees `(&Box, int) -> str`; a decorator on `def bump(mut self, value: int) -> int` sees `(&mut Box, int) -> int`. The wrapper passes the actual receiver borrow through to the decorated callable, so method decorators do not require cloning the receiver.

Class, model, trait, enum, newtype, field, alias, and module decorators remain limited to compiler-owned decorators. Compiler-owned decorators such as `@derive`, `@route`, `@rust.extern`, `@rust.allow`, `@staticmethod`, `@classmethod`, and `@requires` keep their existing special behavior.
Expand Down
3 changes: 2 additions & 1 deletion crates/incan_core/src/lang/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,11 @@ pub const FEATURES: &[FeatureDescriptor] = &[
introduced_in_rfc: RFC::_036,
stability: Stability::Stable,
activation: "None for user-defined decorators; compiler-owned decorators keep their documented imports.",
summary: "Decorators are ordinary callable values applied to functions and methods, including generic decorator factories that infer or accept the decorated function type.",
summary: "Decorators are ordinary callable values applied to functions and methods, including generic decorator factories that infer or accept the decorated function type and decorator helpers that expose `func.__name__`.",
canonical_forms: &[
"@logged",
"@registered(\"catalog.ref\")",
"func.__name__",
"@registered[(str) -> ColumnExpr](\"catalog.ref\")",
],
prefer_over: "Boilerplate wrapper declarations around every function that needs the same callable transform.",
Expand Down
Loading