From ecce17a3fcf5ef298a84c2d91bfa26fdc42f7254 Mon Sep 17 00:00:00 2001 From: Lorenz Holzbauer <73286868+lorenzholzbauer@users.noreply.github.com> Date: Tue, 23 Jul 2024 23:43:08 +0200 Subject: [PATCH] minor (#663): fixed type semantics, used type specifier as template --- .../typeof-type-specifier-expression-semantics.ts | 5 ----- .../typeof-type-specifier-expression.ts | 15 +++++---------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression-semantics.ts b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression-semantics.ts index 9ffece27a..b0962bd43 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression-semantics.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression-semantics.ts @@ -10,9 +10,4 @@ import type { ProcessedType } from "../../../../../semantics"; * @since 0.8.0 */ export interface TypeofTypeSpecifierExpressionSemantics extends TypeSpecifierExpressionSemantics { - /** - * The checked type for this typeof expression. - * @since 0.12.0 - */ - evaluatedType: ProcessedType; } diff --git a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression.ts b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression.ts index a95787d23..bc8820635 100644 --- a/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression.ts +++ b/kipper/core/src/compiler/ast/nodes/expressions/type-specifier-expression/typeof-type-specifier-expression/typeof-type-specifier-expression.ts @@ -8,7 +8,7 @@ import type { CompilableASTNode } from "../../../../compilable-ast-node"; import { TypeSpecifierExpression } from "../type-specifier-expression"; import type { TypeofTypeSpecifierExpressionContext } from "../../../../../lexer-parser"; import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser"; -import { RawType } from "../../../../../semantics"; +import { BuiltInType, BuiltInTypes, RawType } from "../../../../../semantics"; /** * Typeof type specifier expression, which represents a runtime typeof expression evaluating the type of a value. @@ -81,13 +81,8 @@ export class TypeofTypeSpecifierExpression extends TypeSpecifierExpression< * the children has already failed and as such no parent node should run type checking. */ public async primarySemanticAnalysis(): Promise { - const expression = this.children[0]; - - this.programCtx.semanticCheck(this); - this.semanticData = { - evaluatedType: expression.getTypeSemanticData().evaluatedType, - rawType: new RawType(expression.sourceCode) + rawType: new RawType(this.sourceCode) }; } @@ -99,11 +94,11 @@ export class TypeofTypeSpecifierExpression extends TypeSpecifierExpression< public async primarySemanticTypeChecking(): Promise { const semanticData = this.getSemanticData(); - this.programCtx.semanticCheck(this); + const valueType = this.programCtx.typeCheck(this).getCheckedType(semanticData.rawType, this.scope); this.typeSemantics = { - storedType: semanticData.object.g, - evaluatedType: semanticData.object.getTypeSemanticData().evaluatedType, + evaluatedType: BuiltInTypes.type, + storedType: valueType, }; }