fix(compiler): allow integer coercion in range bounds; use for loops in boko-framework
- sema: range bounds now accept compatible integer types (e.g. int..uint) instead of requiring exact type equality. - hir_lower: derive loop variable type from the common range type. - boko-framework: replace manual while loops with for loops in Query_Parse, Request_Parse, Path_Match and App_Run.
This commit is contained in:
+9
-2
@@ -1007,9 +1007,16 @@ proc checkExpr(sema: var Sema, expr: Expr, scope: Scope): Type =
|
||||
of ekRange:
|
||||
let lo = sema.checkExpr(expr.exprRangeLo, scope)
|
||||
let hi = sema.checkExpr(expr.exprRangeHi, scope)
|
||||
if lo != hi:
|
||||
var rangeType: Type = lo
|
||||
if lo == hi:
|
||||
rangeType = lo
|
||||
elif lo.isAssignableTo(hi):
|
||||
rangeType = hi
|
||||
elif hi.isAssignableTo(lo):
|
||||
rangeType = lo
|
||||
else:
|
||||
sema.emitError(expr.loc, "range bounds must have same type")
|
||||
return makeRange(lo)
|
||||
return makeRange(rangeType)
|
||||
of ekCall:
|
||||
if expr.exprCallCallee == nil:
|
||||
sema.emitError(expr.loc, "internal error: nil callee in call expression")
|
||||
|
||||
Reference in New Issue
Block a user