Skip to content

Commit dd6d30c

Browse files
authored
Merge pull request #713 from Kipper-Lang/dev-main
v0.12.1
2 parents e7e9ff9 + 7b460d9 commit dd6d30c

23 files changed

+116
-108
lines changed

CHANGELOG.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ To use development versions of Kipper download the
2828

2929
</details>
3030

31+
## [0.12.1] - 2025-02-17
32+
33+
### Changed
34+
35+
- Renamed:
36+
- Error `MismatchingArgCountBetweenFuncTypesError` to `MismatchingArgCountBetweenFuncTypesTypeError`.
37+
- Error `UnknownTypeError` to `UnknownTypeTypeError`.
38+
- Error `PropertyNotFoundError` to `PropertyNotFoundTypeError`.
39+
40+
### Fixed
41+
42+
- `PropertyNotFoundTypeError` being thrown as a stand-alone error instead of being set as the cause for any parent
43+
assignment operation failure.
44+
- `PropertyNotFoundTypeError` being checked for in the wrong direction i.e. that `otherT` had to have all the properties
45+
of `thisT` instead of the other way around (which is the correct way).
46+
- Indexable checks for `str` and `Array<T>` being accidentally turned off by incorrect logic. This caused
47+
`ValueTypeNotIndexableWithGivenAccessorTypeError` to be only thrown for objects and not for arrays and strings.
48+
3149
## [0.12.0] - 2024-09-25
3250

3351
### Added
@@ -1606,7 +1624,8 @@ To use development versions of Kipper download the
16061624

16071625
- Updated file structure to separate `commands` (for `oclif`) and `compiler` (for the compiler source-code)
16081626

1609-
[unreleased]: https://github.com/Kipper-Lang/Kipper/compare/v0.12.0...HEAD
1627+
[unreleased]: https://github.com/Kipper-Lang/Kipper/compare/v0.12.1...HEAD
1628+
[0.12.1]: https://github.com/Kipper-Lang/Kipper/compare/v0.12.0...v0.12.1
16101629
[0.12.0]: https://github.com/Kipper-Lang/Kipper/compare/v0.11.0...v0.12.0
16111630
[0.11.0]: https://github.com/Kipper-Lang/Kipper/compare/v0.10.4...v0.11.0
16121631
[0.10.4]: https://github.com/Kipper-Lang/Kipper/compare/v0.10.3...v0.10.4

CITATION.cff

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ authors:
2121
identifiers:
2222
- type: url
2323
value: >-
24-
https://github.com/Kipper-Lang/Kipper/releases/tag/v0.12.0
25-
description: The GitHub release URL of tag 0.12.0
24+
https://github.com/Kipper-Lang/Kipper/releases/tag/v0.12.1
25+
description: The GitHub release URL of tag 0.12.1
2626
repository-code: 'https://github.com/Kipper-Lang/Kipper/'
2727
url: 'https://kipper-lang.org'
2828
abstract: >-
@@ -39,6 +39,6 @@ keywords:
3939
- oop-programming
4040
- type-safety
4141
license: GPL-3.0-or-later
42-
license-url: 'https://github.com/Kipper-Lang/Kipper/blob/v0.12.0/LICENSE'
43-
version: 0.12.0
44-
date-released: '2024-09-25'
42+
license-url: 'https://github.com/Kipper-Lang/Kipper/blob/v0.12.1/LICENSE'
43+
version: 0.12.1
44+
date-released: '2025-02-17'

kipper/cli/README.md

+14-19
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ and the [Kipper website](https://kipper-lang.org)._
2222
[![DOI](https://zenodo.org/badge/411260595.svg)](https://zenodo.org/badge/latestdoi/411260595)
2323

2424
<!-- toc -->
25-
26-
- [Kipper CLI - `@kipper/cli` 🦊✨](#kipper-cli---kippercli-)
27-
- [Usage](#usage)
28-
- [Commands](#commands)
25+
* [Kipper CLI - `@kipper/cli` 🦊✨](#kipper-cli---kippercli-)
26+
* [Usage](#usage)
27+
* [Commands](#commands)
2928
<!-- tocstop -->
3029

3130
## General Information
@@ -40,30 +39,27 @@ and the [Kipper website](https://kipper-lang.org)._
4039
# Usage
4140

4241
<!-- usage -->
43-
4442
```sh-session
4543
$ npm install -g @kipper/cli
4644
$ kipper COMMAND
4745
running command...
4846
$ kipper (--version)
49-
@kipper/cli/0.12.0 linux-x64 node-v20.15.0
47+
@kipper/cli/0.12.1 linux-x64 node-v23.4.0
5048
$ kipper --help [COMMAND]
5149
USAGE
5250
$ kipper COMMAND
5351
...
5452
```
55-
5653
<!-- usagestop -->
5754

5855
# Commands
5956

6057
<!-- commands -->
61-
62-
- [`kipper compile [FILE]`](#kipper-compile-file)
63-
- [`kipper help [COMMAND]`](#kipper-help-command)
64-
- [`kipper new [LOCATION]`](#kipper-new-location)
65-
- [`kipper run [FILE]`](#kipper-run-file)
66-
- [`kipper version`](#kipper-version)
58+
* [`kipper compile [FILE]`](#kipper-compile-file)
59+
* [`kipper help [COMMAND]`](#kipper-help-command)
60+
* [`kipper new [LOCATION]`](#kipper-new-location)
61+
* [`kipper run [FILE]`](#kipper-run-file)
62+
* [`kipper version`](#kipper-version)
6763

6864
## `kipper compile [FILE]`
6965

@@ -115,7 +111,7 @@ EXAMPLES
115111
kipper compile -t ts ./path/to/file.kip -o build/ -e utf16le --warnings --log-timestamp
116112
```
117113

118-
_See code: [src/commands/compile.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0/kipper/cli/src/commands/compile.ts)_
114+
_See code: [src/commands/compile.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.1/kipper/cli/src/commands/compile.ts)_
119115

120116
## `kipper help [COMMAND]`
121117

@@ -132,7 +128,7 @@ OPTIONS
132128
--all see all commands in CLI
133129
```
134130

135-
_See code: [src/commands/help.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0/kipper/cli/src/commands/help.ts)_
131+
_See code: [src/commands/help.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.1/kipper/cli/src/commands/help.ts)_
136132

137133
## `kipper new [LOCATION]`
138134

@@ -149,7 +145,7 @@ OPTIONS
149145
-d, --default Use the default settings for the new project. Skips the setup wizard.
150146
```
151147

152-
_See code: [src/commands/new.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0/kipper/cli/src/commands/new.ts)_
148+
_See code: [src/commands/new.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.1/kipper/cli/src/commands/new.ts)_
153149

154150
## `kipper run [FILE]`
155151

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

197-
_See code: [src/commands/run.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0/kipper/cli/src/commands/run.ts)_
193+
_See code: [src/commands/run.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.1/kipper/cli/src/commands/run.ts)_
198194

199195
## `kipper version`
200196

@@ -205,8 +201,7 @@ USAGE
205201
$ kipper version
206202
```
207203

208-
_See code: [src/commands/version.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.0/kipper/cli/src/commands/version.ts)_
209-
204+
_See code: [src/commands/version.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.12.1/kipper/cli/src/commands/version.ts)_
210205
<!-- commandsstop -->
211206

212207
## Contributing to Kipper

kipper/cli/package.json

+1-1
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",
4+
"version": "0.12.1",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"bin": {
77
"kipper": "./bin/run",

kipper/cli/src/index.ts

+1-1
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";
16+
export const version = "0.12.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

+1-1
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",
4+
"version": "0.12.1",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"dependencies": {
77
"is-plain-object": "5.0.0",

kipper/config/src/index.ts

+1-1
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";
15+
export const version = "0.12.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/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@kipper/core",
33
"description": "The core implementation of the Kipper compiler 🦊",
4-
"version": "0.12.0",
4+
"version": "0.12.1",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"dependencies": {
77
"antlr4ts": "^0.5.0-alpha.4",

kipper/core/src/compiler/ast/nodes/root-ast-node.ts

+14-29
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ export class RootASTNode extends ParserASTNode<NoSemantics, NoTypeSemantics> imp
174174
this._children.push(newChild);
175175
}
176176

177+
private async _processAnalysis(toCall: (item: (typeof this.children)[number]) => Promise<void>): Promise<void> {
178+
for (let child of this.children) {
179+
try {
180+
await toCall(child);
181+
} catch (e) {
182+
this.handleSemanticError(<Error>e);
183+
}
184+
}
185+
}
186+
177187
/**
178188
* Semantically analyses the children tokens of this
179189
* {@link RootASTNode instance} and performs additional
@@ -182,41 +192,16 @@ export class RootASTNode extends ParserASTNode<NoSemantics, NoTypeSemantics> imp
182192
*/
183193
public async semanticAnalysis(): Promise<void> {
184194
// Core semantic analysis
185-
for (let child of this.children) {
186-
try {
187-
await child.semanticAnalysis();
188-
} catch (e) {
189-
await this.handleSemanticError(<Error>e);
190-
}
191-
}
195+
await this._processAnalysis((item) => item.semanticAnalysis());
192196

193197
// Perform preliminary semantic analysis in case any specific type evaluation is required prematurely (ahead of
194-
// time type evaluation)
195-
for (let child of this.children) {
196-
try {
197-
await child.preliminaryTypeChecking();
198-
} catch (e) {
199-
await this.handleSemanticError(<Error>e);
200-
}
201-
}
198+
await this._processAnalysis((item) => item.preliminaryTypeChecking());
202199

203200
// Perform type-checking based on the existing AST nodes and evaluated semantics
204-
for (let child of this.children) {
205-
try {
206-
await child.semanticTypeChecking();
207-
} catch (e) {
208-
await this.handleSemanticError(<Error>e);
209-
}
210-
}
201+
await this._processAnalysis((item) => item.semanticTypeChecking());
211202

212203
// Perform wrap-up semantic analysis for the specified target
213-
for (let child of this.children) {
214-
try {
215-
await child.wrapUpSemanticAnalysis();
216-
} catch (e) {
217-
await this.handleSemanticError(<Error>e);
218-
}
219-
}
204+
await this._processAnalysis((item) => item.wrapUpSemanticAnalysis());
220205

221206
// Check for warnings, if they are enabled
222207
if (this.compileConfig.warnings) {

kipper/core/src/compiler/semantics/analyser/type-checker.ts

+6-13
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import {
6767
PropertyDoesNotExistError,
6868
ReadOnlyWriteTypeError,
6969
ReferenceCanNotBeUsedAsTypeError,
70-
UnknownTypeError,
70+
UnknownTypeTypeError,
7171
ValueNotIndexableTypeError,
7272
ValueTypeNotIndexableWithGivenAccessor,
7373
} from "../../../errors";
@@ -93,7 +93,7 @@ export class KipperTypeChecker extends KipperSemanticsAsserter {
9393
public getTypeFromIdentifier(type: string, scope: Scope): ScopeTypeDeclaration {
9494
const scopeEntry = scope.getEntryRecursively(type);
9595
if (scopeEntry === undefined) {
96-
throw this.assertError(new UnknownTypeError(type));
96+
throw this.assertError(new UnknownTypeTypeError(type));
9797
} else if (!(scopeEntry instanceof ScopeTypeDeclaration)) {
9898
throw this.assertError(new ReferenceCanNotBeUsedAsTypeError(type));
9999
}
@@ -665,18 +665,11 @@ export class KipperTypeChecker extends KipperSemanticsAsserter {
665665
return;
666666
}
667667

668-
if (
669-
!objType.isAssignableTo(BuiltInTypes.str) &&
670-
!objType.isAssignableTo(BuiltInTypes.Array) &&
671-
!objType.isAssignableTo(BuiltInTypes.obj)
672-
) {
668+
const isStrOrArr = objType.isAssignableTo(BuiltInTypes.str) || objType.isAssignableTo(BuiltInTypes.Array);
669+
const isObj = objType.isAssignableTo(BuiltInTypes.obj);
670+
if (!isStrOrArr && !isObj) {
673671
throw this.assertError(new ValueNotIndexableTypeError(objType.toString()));
674-
} else if (
675-
(objType.isAssignableTo(BuiltInTypes.str) &&
676-
objType.isAssignableTo(BuiltInTypes.Array) &&
677-
accessType === "dot") ||
678-
(objType.isAssignableTo(BuiltInTypes.obj) && accessType !== "dot")
679-
) {
672+
} else if ((isStrOrArr && accessType === "dot") || (isObj && accessType !== "dot")) {
680673
throw this.assertError(new ValueTypeNotIndexableWithGivenAccessor(objType.toString(), accessType));
681674
}
682675
}

kipper/core/src/compiler/semantics/types/built-in/func.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ArgumentAssignmentTypeError,
66
AssignmentTypeError,
77
GenericArgumentTypeError,
8-
MismatchingArgCountBetweenFuncTypesError,
8+
MismatchingArgCountBetweenFuncTypesTypeError,
99
PropertyAssignmentTypeError,
1010
type TypeError,
1111
} from "../../../../errors";
@@ -86,7 +86,7 @@ export class BuiltInTypeFunc extends GenericBuiltInType<BuiltInTypeFuncGenericAr
8686
const [otherParamTypes, otherReturnType] = (<typeof this>type).genericTypeArguments;
8787

8888
if (paramTypes.type.length !== otherParamTypes.type.length) {
89-
throw new MismatchingArgCountBetweenFuncTypesError(otherParamTypes.type.length, paramTypes.type.length);
89+
throw new MismatchingArgCountBetweenFuncTypesTypeError(otherParamTypes.type.length, paramTypes.type.length);
9090
}
9191

9292
try {

kipper/core/src/compiler/semantics/types/custom-type.ts

+28-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
ArgumentAssignmentTypeError,
55
AssignmentTypeError,
66
PropertyAssignmentTypeError,
7-
PropertyNotFoundError,
7+
PropertyNotFoundTypeError,
88
} from "../../../errors";
99
import type { ClassDeclaration, InterfaceDeclaration, ObjectPrimaryExpression } from "../../ast";
1010
import { BuiltInTypes } from "../symbol-table";
@@ -162,28 +162,44 @@ export class CustomType extends ProcessedType {
162162
* @throws AssignmentTypeError If the types are not assignable.
163163
* @throws PropertyAssignmentTypeError If a property is not assignable.
164164
* @throws ArgumentAssignmentTypeError If an argument is not assignable.
165-
* @throws PropertyNotFoundError If a property is not found.
165+
* @throws PropertyNotFoundTypeError If a property is not found in this type.
166166
* @since 0.12.0
167167
*/
168168
assertAssignableTo(type: ProcessedType, propertyName?: string, argumentName?: string): void {
169169
if (this === type || type === BuiltInTypes.any || type === BuiltInTypes.obj) {
170170
return;
171171
} else if (type instanceof CustomType && type.kind === "interface") {
172-
for (const [fieldName, fieldType] of this.fields) {
173-
const targetTypeField = type.fields.get(fieldName);
174-
if (!targetTypeField) {
175-
throw new PropertyNotFoundError(type.identifier, fieldName);
172+
for (const [fieldName, otherFieldType] of type.fields) {
173+
let caughtError: TypeError | undefined;
174+
175+
const thisFieldType = this.fields.get(fieldName);
176+
if (!thisFieldType) {
177+
caughtError = new PropertyNotFoundTypeError(this.identifier, type.identifier, fieldName);
178+
} else {
179+
try {
180+
thisFieldType.assertAssignableTo(otherFieldType, fieldName);
181+
} catch (error) {
182+
caughtError = <TypeError>error;
183+
}
176184
}
177185

178-
try {
179-
fieldType.assertAssignableTo(targetTypeField, fieldName);
180-
} catch (error) {
186+
if (caughtError) {
181187
if (propertyName) {
182-
throw new PropertyAssignmentTypeError(propertyName, type.identifier, this.identifier, <TypeError>error);
188+
throw new PropertyAssignmentTypeError(
189+
propertyName,
190+
type.identifier,
191+
this.identifier,
192+
<TypeError>caughtError,
193+
);
183194
} else if (argumentName) {
184-
throw new ArgumentAssignmentTypeError(argumentName, type.identifier, this.identifier, <TypeError>error);
195+
throw new ArgumentAssignmentTypeError(
196+
argumentName,
197+
type.identifier,
198+
this.identifier,
199+
<TypeError>caughtError,
200+
);
185201
} else {
186-
throw new AssignmentTypeError(type.identifier, this.identifier, <TypeError>error);
202+
throw new AssignmentTypeError(type.identifier, this.identifier, <TypeError>caughtError);
187203
}
188204
}
189205
}

0 commit comments

Comments
 (0)