mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 09:54:49 +00:00
split again from #24038, fixes https://github.com/status-im/nimbus-eth2/pull/6554#issuecomment-2354977102 `var`/pointer types are no longer implicitly convertible to each other if their element types either: * require an int conversion or another conversion operation as long as it's not to `openarray`, * are subtypes with pointer indirection, Previously any conversion below a subrange match would match if the element type wasn't a pointer type, then it would error later in `analyseIfAddressTaken`. Different from #24038 in that the preview define that made subrange matches also fail to match is removed for a simpler diff so that it can be backported.
17 lines
212 B
Nim
17 lines
212 B
Nim
discard """
|
|
action: reject
|
|
nimout: '''
|
|
but expression 'int(a)' is immutable, not 'var'
|
|
'''
|
|
"""
|
|
|
|
proc `++`(n: var int) =
|
|
n += 1
|
|
|
|
var a: int32 = 15
|
|
|
|
++int(a) #[tt.Error
|
|
^ type mismatch: got <int>]#
|
|
|
|
echo a
|