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
|
if typeRel(c, f.sons[i], a.sons[i]) == isNone: return isNone
|
||||||
result = typeRel(c, f.lastSon, a.lastSon, flags + {trNoCovariance})
|
result = typeRel(c, f.lastSon, a.lastSon, flags + {trNoCovariance})
|
||||||
subtypeCheck()
|
subtypeCheck()
|
||||||
if result <= isConvertible: result = isNone
|
if result <= isIntConv: result = isNone
|
||||||
elif tfNotNil in f.flags and tfNotNil notin a.flags:
|
elif tfNotNil in f.flags and tfNotNil notin a.flags:
|
||||||
result = isNilConversion
|
result = isNilConversion
|
||||||
elif a.kind == tyNil: result = f.allowsNil
|
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](sqlState.addr),
|
||||||
cast[PSQLCHAR](nativeErr.addr),
|
cast[PSQLCHAR](nativeErr.addr),
|
||||||
cast[PSQLCHAR](errMsg.addr),
|
cast[PSQLCHAR](errMsg.addr),
|
||||||
511.TSqlSmallInt, retSz.addr.PSQLSMALLINT)
|
511.TSqlSmallInt, retSz.addr.PSQLINTEGER)
|
||||||
except:
|
except:
|
||||||
discard
|
discard
|
||||||
return (res.int, $(addr sqlState), $(addr nativeErr), $(addr errMsg))
|
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:
|
for colId in 1..cCnt:
|
||||||
buf[0] = '\0'
|
buf[0] = '\0'
|
||||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
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)
|
rowRes[colId-1] = $(addr buf)
|
||||||
cCnt = tempcCnt
|
cCnt = tempcCnt
|
||||||
yield rowRes
|
yield rowRes
|
||||||
|
|
@ -332,7 +333,8 @@ iterator instantRows*(db: var DbConn, query: SqlQuery,
|
||||||
for colId in 1..cCnt:
|
for colId in 1..cCnt:
|
||||||
buf[0] = '\0'
|
buf[0] = '\0'
|
||||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
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)
|
rowRes[colId-1] = $(addr buf)
|
||||||
cCnt = tempcCnt
|
cCnt = tempcCnt
|
||||||
yield (row: rowRes, len: cCnt.int)
|
yield (row: rowRes, len: cCnt.int)
|
||||||
|
|
@ -374,7 +376,8 @@ proc getRow*(db: var DbConn, query: SqlQuery,
|
||||||
for colId in 1..cCnt:
|
for colId in 1..cCnt:
|
||||||
buf[0] = '\0'
|
buf[0] = '\0'
|
||||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
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)
|
rowRes[colId-1] = $(addr buf)
|
||||||
cCnt = tempcCnt
|
cCnt = tempcCnt
|
||||||
res = SQLFetch(db.stmt)
|
res = SQLFetch(db.stmt)
|
||||||
|
|
@ -409,7 +412,8 @@ proc getAllRows*(db: var DbConn, query: SqlQuery,
|
||||||
for colId in 1..cCnt:
|
for colId in 1..cCnt:
|
||||||
buf[0] = '\0'
|
buf[0] = '\0'
|
||||||
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
|
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)
|
rowRes[colId-1] = $(addr buf)
|
||||||
cCnt = tempcCnt
|
cCnt = tempcCnt
|
||||||
rows.add(rowRes)
|
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