Skip to content

Commit 23f5bc0

Browse files
authored
Merge pull request #682 from Kipper-Lang/dev-next
v0.12.0-alpha.1
2 parents ebe956a + d138f5e commit 23f5bc0

140 files changed

Lines changed: 4957 additions & 2680 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.nycrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"**/*.test.ts",
1111
"**/*.spec.ts",
1212
"**/*.d.ts",
13-
"**/*.map"
13+
"**/*.map",
14+
"**/errors.ts"
1415
]
1516
}

CHANGELOG.md

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,54 @@ To use development versions of Kipper download the
1818

1919
### Added
2020

21-
- Added semantic checking and code generation for object literals and object properties.
21+
- Support for dot notation for accessing properties of objects. ([#67](https://github.com/Kipper-Lang/Kipper/issues/67))
22+
- Support for classes, class methods, class properties and class constructors.
23+
([#665](https://github.com/Kipper-Lang/Kipper/issues/665))
24+
- Support for object literals and object properties.
2225
([#526](https://github.com/Kipper-Lang/Kipper/issues/526))
26+
- Support for calling lambdas and functions stored in variables or expressions.
27+
([#674](https://github.com/Kipper-Lang/Kipper/issues/674))
2328
- Implemented internal representation for custom types such as objects, interfaces and classes. This change means that
2429
the entire core type system has been reworked and adjusted to also support custom types as well as complex types
25-
(objects, arrays etc.). This does not inheritely add functionality but serves as the stepping stone for the
30+
(objects, arrays etc.). This does not inherently add functionality but serves as the stepping stone for the
2631
implementation of all custom types in the future. ([#524](https://github.com/Kipper-Lang/Kipper/issues/524))
2732
- Implemented the generic `Array<T>` type and single-type array initializers.
2833
([#499](https://github.com/Kipper-Lang/Kipper/issues/499))
34+
- Support for index-based array assignments. ([#669](https://github.com/Kipper-Lang/Kipper/issues/669))
35+
- Implemented the generic `Func<T..., R>` type and function type initializers.
36+
([#584](https://github.com/Kipper-Lang/Kipper/issues/584))
37+
- Implemented internal generic spread argument `T...`, which allows multiple arguments to be passed to a single
38+
parameter inside a generic type specifier.
39+
- Implemented constant `NaN`, which represents the `NaN` value in JavaScript (Not a Number).
40+
([#671](https://github.com/Kipper-Lang/Kipper/issues/671))
41+
- Support for internal type unions in built-in and internal functions.
42+
([#496](https://github.com/Kipper-Lang/Kipper/issues/496))
2943
- New module:
3044
- `semantics/runtime-built-ins`, which contains runtime built-in functions, variables and types.
3145
- `semantics/runtime-internals`, which contains the runtime internal functions.
3246
- `semantics/types`, which contains the runtime types.
3347
- New classes:
48+
- `UniverseScope`, which represents the universe scope, where all built-in types, functions and variables are
49+
declared. This serves as the parent of the global scope.
3450
- `InterfaceDeclaration`, which represents an AST interface declaration.
51+
- `ClassMethodDeclaration`, which represents an AST class method declaration.
52+
- `ClassPropertyDeclaration`, which represents an AST class property declaration.
53+
- `ClassConstructorDeclaration`, which represents an AST class constructor.
3554
- `ClassDeclaration`, which represents an AST class declaration.
3655
- `BuiltInType`, which represents a built-in type.
3756
- `CustomType`, which represents a user defined type.
57+
- `UnionType`, which represents a union type.
58+
- `BuiltInTypeAny`, which represents the `any` type.
59+
- `BuiltInTypeVoid`, which represents the `void` type.
60+
- `BuiltInTypeNull`, which represents the `null` type.
61+
- `BuiltInTypeUndefined`, which represents the `undefined` type.
62+
- `BuiltInTypeBool`, which represents the `bool` type.
63+
- `BuiltInTypeNum`, which represents the `num` type.
64+
- `BuiltInTypeStr`, which represents the `str` type.
65+
- `BuiltInTypeArray`, which represents the `Array<T>` type.
66+
- `BuiltInTypeFunc`, which represents the `Func<T..., R>` type.
67+
- `BuiltInTypeObj`, which represents the `obj` type.
3868
- `ScopeTypeDeclaration`, which represents a scope type declaration.
39-
- `UniverseTypeDeclaration`, which represents the universe, where all built-in types, functions and variables are
40-
declared. This serves as the parent of the global scope.
4169
- `CustomType`, which is a class extending from `ProcessedType` and implementing the functionality for a custom type such as a interface or class.
4270
- New errors:
4371
- `TypeCanNotBeUsedForTypeCheckingError`, which is thrown when a type is used for type checking, but is not a valid
@@ -48,37 +76,73 @@ To use development versions of Kipper download the
4876
an error indicating an invalid logic that should be fixed.
4977
- `CanNotUseNonGenericAsGenericTypeError`, which is thrown when a non-generic type is used as a generic type. This is
5078
an error indicating an invalid logic that should be fixed.
51-
- New interfaces:
79+
- `MismatchingArgCountBetweenFuncTypesError`, which is thrown when the amount of arguments in a function type does not
80+
match the number of arguments in the function type it is compared to.
81+
- `GenericCanOnlyHaveOneSpreadError`, which is thrown when a generic type has more than one spread argument. This is
82+
for now an internal-only error that should not be thrown in normal circumstances.
83+
- `TypeNotAssignableToUnionError`, which is thrown when a type is not assignable to a union type.
84+
- `ValueTypeNotIndexableWithGivenAccessor`, which is thrown when a value type is not indexable with the given
85+
accessor.
86+
- `PropertyDoesNotExistError`, which is thrown when a property does not exist on a type.
87+
- New interfaces and types:
5288
- `InterfaceDeclarationSemantics`, which represents the semantics of an interface declaration.
5389
- `InterfaceDeclarationTypeSemantics`, which represents the type semantics of an interface declaration.
90+
- `ClassMethodDeclarationSemantics`, which represents the semantics of a class method declaration.
91+
- `ClassMethodDeclarationTypeSemantics`, which represents the type semantics of a class method declaration.
92+
- `ClassPropertyDeclarationSemantics`, which represents the semantics of a class property declaration.
93+
- `ClassPropertyDeclarationTypeSemantics`, which represents the type semantics of a class property declaration.
94+
- `ClassConstructorDeclarationSemantics`, which represents the semantics of a class constructor declaration.
95+
- `ClassConstructorDeclarationTypeSemantics`, which represents the type semantics of a class constructor declaration.
5496
- `ClassDeclarationSemantics`, which represents the semantics of a class declaration.
5597
- `ClassDeclarationTypeSemantics`, which represents the type semantics of a class declaration.
5698
- `TypeDeclaration`, which represents a type declaration. This is an abstract base class for all type declarations.
5799
- `TypeDeclarationSemantics`, which represents the semantics of a type declaration.
58100
- `TypeDeclarationTyp`KipperTypeChecker.validArrayExpression`eSemantics`, which represents the type semantics of a type declaration.
59101
- `CompilableType`, which represents a type that can be compiled.
102+
- `BuiltInReference`, which replaces the now removed type `Reference` in the `KipperProgramContext` for reference
103+
tracking of built-in types.
60104
- New functions:
61105
- `KipperTypeChecker.validArrayExpression`, which ensures that an array expression is valid.
106+
- New properties:
107+
- `BuiltInFunction.funcType`, which returns a function type for the built-in function.
108+
- `FunctionDeclarationTypeSemantics.type`, which returns the type of the function declaration i.e. the function type.
109+
- `LambdaPrimaryExpressionTypeSemantics.type`, which returns the type of the lambda primary expression i.e. the
110+
function type.
111+
- `FunctionCallExpressionTypeSemantics.funcOrExp`, which returns the function or expression that is called. This
112+
always stores some sort of value that extends `BuiltInTypeFunc`.
113+
- New runtime error `KipperError`, which serves as the base for `TypeError` and `IndexError`.
62114

63115
### Changed
64116

65-
- Changed type from interface to class:
117+
- Argument type of built-in function `print` from `str` to `any`.
118+
- Argument type of built-in function `len` from `str` to `str | Array<any>`.
119+
([#667](https://github.com/Kipper-Lang/Kipper/issues/667))
120+
- Type from interface to class:
66121
- `InternalFunction`, which represents an internal function.
67122
- `BuiltInFunction`, which represents a built-in function.
68123
- `InternalFunctionArgument`, which represents an internal function argument.
69124
- `BuiltInVariable`, which represents a built-in variable.
70125
- Renamed:
71126
- Module `analysis` to `semantics`.
127+
- Module `compiler/.../expressions/arithmetic` to `arithmetic-expression`.
72128
- Class `UncheckedType` to `RawType`.
73129
- Class `CheckedType` to `ProcessedType`.
74130
- Class `UndefinedCustomType` to `UndefinedType`.
75131

76132
### Fixed
77133

134+
- All functions and lambdas simply resolving to `Func` instead of the appropriate filled-up `Func<T..., R>` type. This
135+
now enables proper type checking for function references.
136+
- CLI command `run` not properly reporting internal or unexpected errors, as they were already prettified in the
137+
internally called up command `compile`.
138+
78139
### Deprecated
79140

80141
### Removed
81142

143+
- Type `Reference` as it is no longer needed and has been replaced by `KipperReferenceable`.
144+
- `FunctionCallExpressionTypeSemantics.func`, which is now has been replaced by `funcOrExp`.
145+
82146
</details>
83147

84148
## [0.11.0] - 2024-07-10

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ authors:
1313
identifiers:
1414
- type: url
1515
value: >-
16-
https://github.com/Kipper-Lang/Kipper/releases/tag/v0.12.0-alpha.0
16+
https://github.com/Kipper-Lang/Kipper/releases/tag/v0.12.0-alpha.1
1717
description: The GitHub release URL of tag 0.12.0-alpha.0
1818
repository-code: 'https://github.com/Kipper-Lang/Kipper/'
1919
url: 'https://kipper-lang.org'
@@ -31,6 +31,6 @@ keywords:
3131
- oop-programming
3232
- type-safety
3333
license: GPL-3.0-or-later
34-
license-url: 'https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.0/LICENSE'
34+
license-url: 'https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.1/LICENSE'
3535
version: 0.12.0-alpha.0
3636
date-released: '2024-07-01'

kipper/cli/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ $ npm install -g @kipper/cli
4444
$ kipper COMMAND
4545
running command...
4646
$ kipper (--version)
47-
@kipper/cli/0.12.0-alpha.0 linux-x64 node-v20.10.0
47+
@kipper/cli/0.12.0-alpha.1 linux-x64 node-v18.18.2
4848
$ kipper --help [COMMAND]
4949
USAGE
5050
$ kipper COMMAND
@@ -111,7 +111,7 @@ EXAMPLES
111111
kipper compile -t ts ./path/to/file.kip -o build/ -e utf16le --warnings --log-timestamp
112112
```
113113

114-
_See code: [src/commands/compile.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.0/kipper/cli/src/commands/compile.ts)_
114+
_See code: [src/commands/compile.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.1/kipper/cli/src/commands/compile.ts)_
115115

116116
## `kipper help [COMMAND]`
117117

@@ -128,7 +128,7 @@ OPTIONS
128128
--all see all commands in CLI
129129
```
130130

131-
_See code: [src/commands/help.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.0/kipper/cli/src/commands/help.ts)_
131+
_See code: [src/commands/help.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.1/kipper/cli/src/commands/help.ts)_
132132

133133
## `kipper new [LOCATION]`
134134

@@ -145,7 +145,7 @@ OPTIONS
145145
-d, --default Use the default settings for the new project. Skips the setup wizard.
146146
```
147147

148-
_See code: [src/commands/new.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.0/kipper/cli/src/commands/new.ts)_
148+
_See code: [src/commands/new.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.1/kipper/cli/src/commands/new.ts)_
149149

150150
## `kipper run [FILE]`
151151

@@ -190,7 +190,7 @@ EXAMPLES
190190
kipper run -t ts -o build/ -e utf8 -s "print('Hello, World!');" --warnings --log-timestamp
191191
```
192192

193-
_See code: [src/commands/run.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.0/kipper/cli/src/commands/run.ts)_
193+
_See code: [src/commands/run.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.1/kipper/cli/src/commands/run.ts)_
194194

195195
## `kipper version`
196196

@@ -201,7 +201,7 @@ USAGE
201201
$ kipper version
202202
```
203203

204-
_See code: [src/commands/version.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.0/kipper/cli/src/commands/version.ts)_
204+
_See code: [src/commands/version.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0-alpha.1/kipper/cli/src/commands/version.ts)_
205205
<!-- commandsstop -->
206206

207207
## Contributing to Kipper

kipper/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@kipper/cli",
33
"description": "The Kipper Command Line Interface (CLI).",
4-
"version": "0.12.0-alpha.0",
4+
"version": "0.12.0-alpha.1",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"bin": {
77
"kipper": "./bin/run",

kipper/cli/src/decorators.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,45 @@ export function prettifiedErrors<TProto extends Command>() {
2323
try {
2424
return await originalFunc.call(this, ...argArray);
2525
} catch (error) {
26+
if ("prettified" in <Error>error && (<OclifCLIError & { prettified?: boolean }>error).prettified) {
27+
throw error; // Rethrow the error, since it has already been prettified
28+
}
29+
2630
const cliError = error instanceof KipperCLIError || error instanceof OclifCLIError;
2731
const configError = error instanceof ConfigError;
2832
const internalError = error instanceof KipperInternalError;
33+
const unexpectedError = internalError || (!cliError && !configError);
2934

30-
// Error configuration
3135
const name: string = getErrorName(cliError, configError, internalError);
32-
const msg: string =
36+
let msg: string =
3337
error && typeof error === "object" && "message" in error && typeof error.message === "string"
34-
? error.message
38+
? unexpectedError
39+
? // prettier-ignore
40+
((<Error>error)?.stack ?? error.message)
41+
: error.message
3542
: String(error);
43+
3644
// prettier-ignore
3745
const errConfig: { exit: number } & PrettyPrintableError = {
3846
exit: 1,
3947
suggestions:
40-
internalError || (!cliError && !configError)
48+
unexpectedError
4149
? [
42-
"Ensure no invalid types or data were passed to module functions or classes. Otherwise report the " +
43-
"issue on https://github.com/Kipper-Lang/Kipper. Help us improve Kipper!️",
44-
]
50+
"Ensure no invalid types or data were passed to module functions or classes. Otherwise report the " +
51+
"issue on https://github.com/Kipper-Lang/Kipper. Help us improve Kipper!️",
52+
]
4553
: undefined,
4654
};
4755

4856
// 'Command.error' (i.e. 'this.error') will throw the CLI error we want, which means we need to catch it and
4957
// modify it, so we have the correct result we want
5058
try {
5159
this.error(msg, errConfig);
52-
} catch (e) {
53-
(<OclifCLIError>e).name = name;
60+
} catch (oclifError) {
61+
(<OclifCLIError>oclifError).name = name;
62+
(<OclifCLIError & { prettified?: boolean }>oclifError).prettified = true;
5463

55-
throw e; // Rethrowing it -> Oclif will pretty print it
64+
throw oclifError; // Rethrowing it -> Oclif will pretty print it
5665
}
5766
}
5867
};

kipper/cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export * from "./output/compile";
1313
// eslint-disable-next-line no-unused-vars
1414
export const name = "@kipper/cli";
1515
// eslint-disable-next-line no-unused-vars
16-
export const version = "0.12.0-alpha.0";
16+
export const version = "0.12.0-alpha.1";
1717
// eslint-disable-next-line no-unused-vars
1818
export const author = "Luna Klatzer";
1919
// eslint-disable-next-line no-unused-vars

kipper/config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@kipper/config",
33
"description": "The config file support package adding support for kip-config.json/kipper-config.json 🦊",
4-
"version": "0.12.0-alpha.0",
4+
"version": "0.12.0-alpha.1",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"dependencies": {
77
"is-plain-object": "5.0.0",

kipper/config/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export * from "./evaluated-kipper-config-file";
1212
// eslint-disable-next-line no-unused-vars
1313
export const name = "@kipper/config";
1414
// eslint-disable-next-line no-unused-vars
15-
export const version = "0.12.0-alpha.0";
15+
export const version = "0.12.0-alpha.1";
1616
// eslint-disable-next-line no-unused-vars
1717
export const author = "Luna Klatzer";
1818
// eslint-disable-next-line no-unused-vars

kipper/core/KipperLexer.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ RetIndicator : '->';
8080
// class and interface-related
8181
Class : 'class';
8282
Interface : 'interface';
83+
Constructor : 'constructor';
8384

8485
// boolean constants
8586
True : 'true';

0 commit comments

Comments
 (0)