Restrict ptr/ref to ptr/ref implicit conversion (#10411)
* Restrict ptr/ref to ptr/ref implicit conversion Fixes #10409 * Make the ptr conversions explicit in db_odbc
This commit is contained in:
parent
39e1cd2bf6
commit
6825430831
3 changed files with 18 additions and 6 deletions
|
|
@ -1316,7 +1316,7 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
|||
if typeRel(c, f.sons[i], a.sons[i]) == isNone: return isNone
|
||||
result = typeRel(c, f.lastSon, a.lastSon, flags + {trNoCovariance})
|
||||
subtypeCheck()
|
||||
if result <= isConvertible: result = isNone
|
||||
if result <= isIntConv: result = isNone
|
||||
elif tfNotNil in f.flags and tfNotNil notin a.flags:
|
||||
result = isNilConversion
|
||||
elif a.kind == tyNil: result = f.allowsNil
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ proc getErrInfo(db: var DbConn): tuple[res: int, ss, ne, msg: string] {.
|
|||
cast[PSQLCHAR](sqlState.addr),
|
||||
cast[PSQLCHAR](nativeErr.addr),
|
||||
cast[PSQLCHAR](errMsg.addr),
|
||||
511.TSqlSmallInt, retSz.addr.PSQLSMALLINT)
|
||||
511.TSqlSmallInt, retSz.addr.PSQLINTEGER)
|
||||
except:
|
||||
discard
|
||||
return (res.int, $(addr sqlState), $(addr nativeErr), $(addr errMsg))
|
||||
|
|
@ -297,7 +297,8 @@ iterator fastRows*(db: var DbConn, query: SqlQuery,
|
|||
for colId in 1..cCnt:
|
||||
buf[0] = '\0'
|
||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
||||
cast[cstring](buf.addr), 4095.TSqlSmallInt, sz.addr))
|
||||
cast[cstring](buf.addr), 4095.TSqlSmallInt,
|
||||
sz.addr.PSQLINTEGER))
|
||||
rowRes[colId-1] = $(addr buf)
|
||||
cCnt = tempcCnt
|
||||
yield rowRes
|
||||
|
|
@ -332,7 +333,8 @@ iterator instantRows*(db: var DbConn, query: SqlQuery,
|
|||
for colId in 1..cCnt:
|
||||
buf[0] = '\0'
|
||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
||||
cast[cstring](buf.addr), 4095.TSqlSmallInt, sz.addr))
|
||||
cast[cstring](buf.addr), 4095.TSqlSmallInt,
|
||||
sz.addr.PSQLINTEGER))
|
||||
rowRes[colId-1] = $(addr buf)
|
||||
cCnt = tempcCnt
|
||||
yield (row: rowRes, len: cCnt.int)
|
||||
|
|
@ -374,7 +376,8 @@ proc getRow*(db: var DbConn, query: SqlQuery,
|
|||
for colId in 1..cCnt:
|
||||
buf[0] = '\0'
|
||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
||||
cast[cstring](buf.addr), 4095.TSqlSmallInt, sz.addr))
|
||||
cast[cstring](buf.addr), 4095.TSqlSmallInt,
|
||||
sz.addr.PSQLINTEGER))
|
||||
rowRes[colId-1] = $(addr buf)
|
||||
cCnt = tempcCnt
|
||||
res = SQLFetch(db.stmt)
|
||||
|
|
@ -409,7 +412,8 @@ proc getAllRows*(db: var DbConn, query: SqlQuery,
|
|||
for colId in 1..cCnt:
|
||||
buf[0] = '\0'
|
||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
||||
cast[cstring](buf.addr), 4095.TSqlSmallInt, sz.addr))
|
||||
cast[cstring](buf.addr), 4095.TSqlSmallInt,
|
||||
sz.addr.PSQLINTEGER))
|
||||
rowRes[colId-1] = $(addr buf)
|
||||
cCnt = tempcCnt
|
||||
rows.add(rowRes)
|
||||
|
|
|
|||
8
tests/typerel/tptrs.nim
Normal file
8
tests/typerel/tptrs.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
discard """
|
||||
errormsg: "type mismatch: got <ptr int16> but expected 'ptr int'"
|
||||
line: 8
|
||||
"""
|
||||
|
||||
var
|
||||
n: int16
|
||||
p: ptr int = addr n
|
||||
Loading…
Add table
Add a link
Reference in a new issue