diff options
author | narimiran <narimiran@disroot.org> | 2019-08-27 14:49:32 +0200 |
---|---|---|
committer | narimiran <narimiran@disroot.org> | 2019-08-27 14:49:32 +0200 |
commit | 329e169e964951b39cee863dd715277166497213 (patch) | |
tree | 1325c32b32b9f4e2a45703a58dbaa54b85ee5c61 | |
parent | def623490345e12b12a07efcc37f81d27926f0ec (diff) | |
download | Nim-329e169e964951b39cee863dd715277166497213.tar.gz |
address the comments
-rw-r--r-- | compiler/sem.nim | 1 | ||||
-rw-r--r-- | compiler/semexprs.nim | 7 | ||||
-rw-r--r-- | compiler/semstmts.nim | 3 |
3 files changed, 4 insertions, 7 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim index 119393e25..194f88809 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -444,6 +444,7 @@ proc semAfterMacroCall(c: PContext, call, macroResult: PNode, const errMissingGenericParamsForTemplate = "'$1' has unspecified generic parameters" + errFloatToString = "cannot convert '$1' to '$2'" proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym, flags: TExprFlags = {}): PNode = diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 735f2646f..765110d56 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -514,11 +514,8 @@ proc changeType(c: PContext; n: PNode, newType: PType, check: bool) = localError(c.config, n.info, "cannot convert " & $value & " to " & typeToString(newType)) of nkFloatLit..nkFloat64Lit: - if check: - echo newType.kind - if not floatRangeCheck(n.floatVal, newType): - localError(c.config, n.info, "cannot convert " & $n.floatVal & - " to " & typeToString(newType)) + if check and not floatRangeCheck(n.floatVal, newType): + localError(c.config, n.info, errFloatToString % [$n.floatVal, typeToString(newType)]) else: discard n.typ = newType diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 9c67fa565..5a9c92647 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -293,8 +293,7 @@ proc fitRemoveHiddenConv(c: PContext, typ: PType, n: PNode): PNode = result.info = n.info result.typ = typ if not floatRangeCheck(result.floatVal, typ): - localError(c.config, n.info, "cannot convert " & $result.floatVal & - " to " & typeToString(typ)) + localError(c.config, n.info, errFloatToString % [$n.floatVal, typeToString(typ)]) else: changeType(c, r1, typ, check=true) result = r1 |