unyt-org/datex

Implement `as <type>` declaration

Offen

#259 geöffnet am 26.08.2025

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Rust (2 Forks)github user discovery
designgood first issuescope:compiler

Repository-Metriken

Stars
 (14 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 53T 4h) (6 gemergte PRs in 30 T)

Beschreibung

We need as <type> declarations for the compiler (if we are smarter) and also for the runtime. This should be a

var x: integer | text = 42
// x is integer | text

var y = x as integer // x is asserted to be integer and typeof y is integer
var y = x as text // x is asserted to be text (invalid, throws)
@example :: (1 + 2)

Compiler has to inject a assertion such as

@example :: (1 + 2) as integer

if we can not analyze the remote code (due to missing types), it will be treated as "unknown" and we have to cast/match to use for further processing (such as apply chains)

  • Implement in grammar
  • Implement in compiler
  • Implement in runtime

Contributor Guide