Type Aliases!

This commit is contained in:
Dustin Swan 2026-04-12 20:26:16 -06:00
parent 32815301fa
commit 25c3ac5c0d
No known key found for this signature in database
GPG key ID: 30D46587E2100467
3 changed files with 47 additions and 2 deletions

View file

@ -715,6 +715,13 @@ export class Parser {
this.expect('equals');
// If next token isn't a type-ident, it's a type alias
if (this.current().kind !== 'type-ident') {
const alias = this.parseType();
if (this.current().kind === 'semicolon') this.advance();
return { kind: 'type-definition', name, params, constructors: [], alias, ...this.getPos(nameToken) };
}
// Parse constructors separated by |
const constructors: TypeConstructor[] = [];
constructors.push(this.parseTypeConstructor());