Skip to content

Commit

Permalink
fix: Python generation for type casts
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Apr 6, 2024
1 parent 8d22e67 commit aa97a0b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
isSdsTemplateStringInner,
isSdsTemplateStringPart,
isSdsTemplateStringStart,
isSdsTypeCast,
isSdsWildcard,
isSdsYield,
SdsArgument,
Expand Down Expand Up @@ -907,6 +908,8 @@ export class SafeDsPythonGenerator {
const referenceImport = this.createImportDataForReference(expression);
frame.addImport(referenceImport);
return traceToNode(expression)(referenceImport?.alias ?? this.getPythonNameOrDefault(declaration));
} else if (isSdsTypeCast(expression)) {
return traceToNode(expression)(this.generateExpression(expression.expression, frame));
}
/* c8 ignore next 2 */
throw new Error(`Unknown expression type: ${expression.$type}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Segments ---------------------------------------------------------------------

def mySegment(p):
a = p

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package tests.generation.expressions.typeCasts

segment mySegment(p: Int) {
val a = p as Int;
}

0 comments on commit aa97a0b

Please sign in to comment.