Skip to content

Commit 7d39ee6

Browse files
Fix double-long conversion.
1 parent 758e876 commit 7d39ee6

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/backend/llvm.nt

+1-1
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ class LLVMBackendFunction : BackendFunction, PhiCapable {
997997
auto def = this.regDefines.get(reg).case(:notFound: die);
998998
auto from = def.type;
999999
bool isInt(BackendType type) {
1000-
return !!type.instanceOf(BackendIntType);
1000+
return type.instanceOf(BackendIntType) || type.instanceOf(BackendLongType);
10011001
}
10021002
bool isFloat(BackendType type) {
10031003
return type.instanceOf(BackendFloatType) || type.instanceOf(BackendDoubleType);

src/neat/expr.nt

+2-1
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,8 @@ class CastExpr : Expression
953953
}
954954
if (type.instanceOf(Float) && this.target.instanceOf(Integer) ||
955955
type.instanceOf(Double) && this.target.instanceOf(Integer) ||
956-
type.instanceOf(Double) && this.target.instanceOf(Float))
956+
type.instanceOf(Double) && this.target.instanceOf(Float) ||
957+
type.instanceOf(Double) && this.target.instanceOf(Long))
957958
{
958959
return generator.fun.convert(value, target);
959960
}

test/runnable/floattest.nt

+2
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ void main() {
1010
float h = -3.5;
1111
assert(0 - 4f == -4.0f);
1212
assert(100_000f == 100_000.0f);
13+
assert(cast(int) 1234.0f == 1234);
14+
assert(cast(long) 1234.0 == 1234);
1315
}

0 commit comments

Comments
 (0)