1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-24 15:29:23 +00:00

Fix >32bit constants

This commit is contained in:
Karol Stasiak 2020-03-26 01:36:41 +01:00
parent 5215400cb2
commit 2a3c9f04be

View File

@ -1814,8 +1814,8 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
if (stmt.initialValue.isEmpty) log.error(s"`$name` is a constant and requires a value", position) if (stmt.initialValue.isEmpty) log.error(s"`$name` is a constant and requires a value", position)
val rawConstantValue = stmt.initialValue.flatMap(eval).getOrElse(errorConstant(s"`$name` has a non-constant value", position)).quickSimplify val rawConstantValue = stmt.initialValue.flatMap(eval).getOrElse(errorConstant(s"`$name` has a non-constant value", position)).quickSimplify
rawConstantValue match { rawConstantValue match {
case NumericConstant(nv, _) if nv >= 2 => case NumericConstant(nv, _) if nv >= 2 && typ.size < 8 =>
if (nv >= 1.<<(8*typ.size)) { if (nv >= 1L.<<(8*typ.size)) {
log.error(s"Constant value $nv too big for type ${typ.name}", stmt.position) log.error(s"Constant value $nv too big for type ${typ.name}", stmt.position)
} }
case _ => // ignore case _ => // ignore