dt error details

This commit is contained in:
Irmen de Jong 2024-01-12 00:27:39 +01:00
parent bc3f2db3de
commit 0c1018ec61
7 changed files with 11 additions and 8 deletions

View File

@ -338,7 +338,7 @@ class AsmGen6502Internal (
DataType.UWORD -> "cx16.r9"
DataType.WORD -> "cx16.r9s"
DataType.FLOAT -> "floats.floats_temp_var"
else -> throw AssemblyError("invalid dt $dt")
else -> throw AssemblyError("invalid dt")
}
}

View File

@ -270,7 +270,7 @@ internal class BuiltinFuncGen(private val codeGen: IRCodeGen, private val exprGe
}
return ExpressionCodeResult(result, IRDataType.FLOAT, -1, resultFpReg)
}
else -> throw AssemblyError("invalid dt for sqrt")
else -> throw AssemblyError("invalid dt")
}
}

View File

@ -3,7 +3,6 @@ package prog8.compiler.astprocessing
import prog8.ast.IStatementContainer
import prog8.ast.Node
import prog8.ast.Program
import prog8.ast.base.FatalAstException
import prog8.ast.expressions.BinaryExpression
import prog8.ast.expressions.NumericLiteral
import prog8.ast.statements.*
@ -35,7 +34,7 @@ internal class BeforeAsmAstChanger(val program: Program, private val options: Co
override fun after(scope: AnonymousScope, parent: Node): Iterable<IAstModification> {
if(scope.statements.any { it is VarDecl || it is IStatementContainer })
throw FatalAstException("anonymousscope may no longer contain any vardecls or subscopes")
throw InternalCompilerException("anonymousscope may no longer contain any vardecls or subscopes")
return noModifications
}

View File

@ -102,7 +102,7 @@ internal class NotExpressionAndIfComparisonExprChanger(val program: Program, val
// not(~x) -> x!=0
if((expr.expression as? PrefixExpression)?.operator=="~") {
val x = (expr.expression as PrefixExpression).expression
val dt = x.inferType(program).getOrElse { throw FatalAstException("invalid dt") }
val dt = x.inferType(program).getOrElse { throw FatalAstException("invalid dt ${x.position}") }
val notZero = BinaryExpression(x, "!=", NumericLiteral(dt, 0.0, expr.position), expr.position)
return listOf(IAstModification.ReplaceNode(expr, notZero, parent))
}

View File

@ -58,7 +58,7 @@ internal class VariousCleanups(val program: Program, val errors: IErrorReporter,
return listOf(IAstModification.ReplaceNode(typecast, typecast.expression, parent))
if(parent is Assignment) {
val targetDt = (parent).target.inferType(program).getOrElse { throw FatalAstException("invalid dt") }
val targetDt = parent.target.inferType(program).getOrElse { throw FatalAstException("invalid dt ${parent.target.position}") }
if(sourceDt istype targetDt) {
// we can get rid of this typecast because the type is already the target type
return listOf(IAstModification.ReplaceNode(typecast, typecast.expression, parent))

View File

@ -1,6 +1,8 @@
TODO
====
Mark had a compiler crash FatalAstException: invalid dt
...
@ -9,6 +11,8 @@ Future Things and Ideas
Compiler:
- get rid of the noshortcircuit fallback option and code.
- instead of copy-pasting inline asmsubs, make them into a 64tass macro and use that instead.
that will allow them to be reused from custom user written assembly code as well.
- Multidimensional arrays and chained indexing, purely as syntactic sugar over regular arrays.
- make a form of "manual generics" possible like: varsub routine(T arg)->T where T is expanded to a specific type
(this is already done hardcoded for several of the builtin functions)

View File

@ -503,7 +503,7 @@ class IRFileReader {
"bool" -> DataType.ARRAY_B
"uword_split" -> DataType.ARRAY_UW_SPLIT
"word_split" -> DataType.ARRAY_W_SPLIT
else -> throw IRParseException("invalid dt $type")
else -> throw IRParseException("invalid dt")
}
} else {
return when(type) {
@ -514,7 +514,7 @@ class IRFileReader {
"float" -> DataType.FLOAT
"bool" -> DataType.BOOL
// note: 'str' should not occur anymore in IR. Should be 'uword'
else -> throw IRParseException("invalid dt $type")
else -> throw IRParseException("invalid dt")
}
}
}