remove deprecated type pragma syntax, fix bugs that required it (#20199)

* remove deprecated pragma syntax from 0.20.0

closes #4651, closes #16653 with a cheap fix for now due to
how early `tfFinal` is set

* remove type pragma between name and generics

* undo removal, try removing bind expression (0.8.14)

* fix test, unremove bind expr

* remove again

* Update changelog.md

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* dependencies @ HEAD & weave test dependencies

* try fix package ci

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
This commit is contained in:
metagn
2022-09-03 10:52:13 +03:00
committed by GitHub
parent f540fd5cde
commit 86f7f4ffa5
44 changed files with 111 additions and 86 deletions

View File

@@ -80,7 +80,7 @@ block tcopy:
block tgenericassign:
type
TAny = object {.pure.}
TAny {.pure.} = object
value: pointer
rawType: pointer

View File

@@ -561,7 +561,7 @@ when isMainModule:
echo "got the ident m"
testRecCase:
type Obj[T] = object {.inheritable.}
type Obj[T] {.inheritable.} = object
name: string
case isFat: bool
of true:

View File

@@ -1,9 +1,10 @@
discard """
errormsg: "ambiguous call"
file: "tbind2.nim"
line: 12
file: "told_bind_expr.nim"
line: 13
"""
# Test the new ``bind`` keyword for templates
# Pre-0.9 deprecated bind expression syntax
proc p1(x: int8, y: int): int = return x + y
proc p1(x: int, y: int8): int = return x - y

View File

@@ -29,7 +29,7 @@ template test =
var b = 1
say (b += 1; b), (b += 1; b) #2,3
type C = object {.byRef.}
type C {.byRef.} = object
i: int
proc say(a, b: C) =

View File

@@ -7,7 +7,7 @@ type
Features: seq[Feature] # Read-Only
PNode* = ref Node
Node = object {.inheritable.}
Node {.inheritable.} = object
attributes*: seq[PAttr]
childNodes*: seq[PNode]
FLocalName: string # Read-only

View File

@@ -11,7 +11,7 @@ type
className* : string
TClassOfTobj = object of TClassOfTCustomObject
nil
TCustomObject = ref object {.inheritable.}
TCustomObject {.inheritable.} = ref object
class* : ptr TClassOfTCustomObject
TObj = ref object of TCustomObject
data: int

View File

@@ -20,7 +20,7 @@ template <typename X> class C {
};
""".}
type C{.importcpp, header: "<stdio.h>", nodecl.} [X] = object
type C[X] {.importcpp, header: "<stdio.h>", nodecl.} = object
proc mkC[X]: C[X] {.importcpp: "C<'*0>()", constructor, nodecl.}
proc foo(): C[int] =

View File

@@ -8,7 +8,7 @@ disabled: "windows" # pending bug #18011
# bug #4730
type Vector* {.importcpp: "std::vector", header: "<vector>".}[T] = object
type Vector*[T] {.importcpp: "std::vector", header: "<vector>".} = object
template `[]=`*[T](v: var Vector[T], key: int, val: T) =
{.emit: [v, "[", key, "] = ", val, ";"].}

View File

@@ -12,8 +12,8 @@ struct Vector {
""".}
type
Vector {.importcpp: "Vector".} [T] = object
VectorIterator {.importcpp: "Vector<'0>::Iterator".} [T] = object
Vector[T] {.importcpp: "Vector".} = object
VectorIterator[T] {.importcpp: "Vector<'0>::Iterator".} = object
var x: VectorIterator[void]

View File

@@ -4,7 +4,7 @@ discard """
"""
{.push warningAsError[Effect]: on.}
type
TObj = object {.pure, inheritable.}
TObj {.pure, inheritable.} = object
TObjB = object of TObj
a, b, c: string

View File

@@ -4,7 +4,7 @@ discard """
"""
type
TObj = object {.pure, inheritable.}
TObj {.pure, inheritable.} = object
TObjB = object of TObj
a, b, c: string
fn: proc (): int {.tags: [].}

View File

@@ -4,7 +4,7 @@ discard """
"""
type
TObj = object {.pure, inheritable.}
TObj {.pure, inheritable.} = object
TObjB = object of TObj
a, b, c: string
fn: proc (): int {.tags: [ReadIOEffect].}

View File

@@ -9,7 +9,7 @@ tinvalidinout.nim(18, 9) Error: the 'in' modifier can be used only with imported
"""
type
Foo {.header: "foo.h", importcpp.} [in T] = object
Foo[in T] {.header: "foo.h", importcpp.} = object
Bar[out X] = object
x: int

View File

@@ -76,7 +76,7 @@ doAssert(getCurrentException() == nil)
# raise by pointer and also generic type
type
std_vector {.importcpp"std::vector", header"<vector>".} [T] = object
std_vector[T] {.importcpp"std::vector", header"<vector>".} = object
proc newVector[T](len: int): ptr std_vector[T] {.importcpp: "new std::vector<'1>(@)".}
proc deleteVector[T](v: ptr std_vector[T]) {.importcpp: "delete @; @ = NIM_NIL;".}

View File

@@ -1,5 +1,5 @@
type
Base[T] = ref object {.inheritable.}
Base[T] {.inheritable.} = ref object
value*: T
Derived[T] = ref object of Base[T]

View File

@@ -31,7 +31,7 @@ block tinherit:
block tspecialise:
type
TGen[T] = object {.inheritable.}
TGen[T] {.inheritable.} = object
TSpef = object of TGen[string]

View File

@@ -12,7 +12,7 @@ import strutils
type
PNode[T,D] = ref TNode[T,D]
TItem {.acyclic, pure, final, shallow.} [T,D] = object
TItem[T,D] {.acyclic, pure, final, shallow.} = object
key: T
value: D
node: PNode[T,D]
@@ -20,7 +20,7 @@ type
val_set: bool
TItems[T,D] = seq[ref TItem[T,D]]
TNode {.acyclic, pure, final, shallow.} [T,D] = object
TNode[T,D] {.acyclic, pure, final, shallow.} = object
slots: TItems[T,D]
left: PNode[T,D]
count: int32

View File

@@ -0,0 +1,10 @@
discard """
targets: "cpp"
action: compile
"""
# #4651
type
Vector[T] {.importcpp: "std::vector<'0 >", header: "vector", inheritable.} = object
VectorDerived {.importcpp: "SomeVectorDerived", nodecl.} = object of Vector[int]
# Error: inheritance only works with non-final objects

View File

@@ -17,7 +17,7 @@ type
TSlotEnum = enum seEmpty, seFilled, seDeleted
TKeyValuePair[A, B] = tuple[slot: TSlotEnum, key: A, val: B]
TKeyValuePairSeq[A, B] = seq[TKeyValuePair[A, B]]
TTable* {.final.}[A, B] = object
TTable*[A, B] {.final.} = object
data: TKeyValuePairSeq[A, B]
counter: int

View File

@@ -191,14 +191,14 @@ template myAttr3() {.pragma.}
template serializationKey(key: string) {.pragma.}
type
MyObj = object {.packed,myAttr,serializationKey: "one".}
MyObj {.packed,myAttr,serializationKey: "one".} = object
myField {.myAttr2,serializationKey: "two".}: int
myField2 {.myAttr3,serializationKey: "three".}: float
# field pragmas not currently supported
test(MyObj):
type
_ = object {.packed,myAttr,serializationKey: "one".}
_ {.packed,myAttr,serializationKey: "one".} = object
myField: int
myField2: float

View File

@@ -18,7 +18,7 @@ type
# it's also possible to use a strongly typed tuple here
VTable = array[0..1, pointer]
TBase = object {.inheritable.}
TBase {.inheritable.} = object
vtbl: ptr VTable
TUserObject1 = object of TBase

View File

@@ -10,7 +10,7 @@ type B
# bug #1659
type Animal = ref object {.inheritable.}
type Animal {.inheritable.} = ref object
type Dog = ref object of Animal
method say(a: Animal): auto {.base.} = "wat!"

View File

@@ -12,7 +12,7 @@ method somethin(obj: RootObj) {.base.} =
echo "do nothing"
type
TNode* = object {.inheritable.}
TNode* {.inheritable.} = object
PNode* = ref TNode
PNodeFoo* = ref object of TNode
@@ -30,7 +30,7 @@ o.somethin()
# tmproto
type
Obj1 = ref object {.inheritable.}
Obj1 {.inheritable.} = ref object
Obj2 = ref object of Obj1
method beta(x: Obj1): int {.base.}

View File

@@ -16,7 +16,7 @@ do nothing
# tmultim2
type
TThing = object {.inheritable.}
TThing {.inheritable.} = object
TUnit = object of TThing
x: int
TParticle = object of TThing
@@ -49,7 +49,7 @@ staticCollide(a, b)
# tmultim6
type
Thing = object {.inheritable.}
Thing {.inheritable.} = object
Unit[T] = object of Thing
x: T
Particle = object of Thing
@@ -81,7 +81,7 @@ method somethin(obj: RootObj) {.base.} =
echo "do nothing"
type
TNode* = object {.inheritable.}
TNode* {.inheritable.} = object
PNode* = ref TNode
PNodeFoo* = ref object of TNode

View File

@@ -10,7 +10,7 @@ type
TSlotEnum = enum seEmpty, seFilled, seDeleted
TKeyValuePair[A, B] = tuple[slot: TSlotEnum, key: A, val: B]
TKeyValuePairSeq[A, B] = seq[TKeyValuePair[A, B]]
TTable* {.final, myShallow.}[A, B] = object
TTable*[A, B] {.final, myShallow.} = object
data: TKeyValuePairSeq[A, B]
counter: int
@@ -137,8 +137,7 @@ proc `$`*[A, B](t: TTable[A, B]): string =
# ------------------------------ count tables -------------------------------
type
TCountTable* {.final, myShallow.}[
A] = object ## table that counts the number of each key
TCountTable*[A] {.final, myShallow.} = object ## table that counts the number of each key
data: seq[tuple[key: A, val: int]]
counter: int

View File

@@ -15,8 +15,8 @@ echo s[0].x
# bug #563
type
Foo =
object {.inheritable.}
Foo {.inheritable.} =
object
x: int
Bar =

View File

@@ -31,7 +31,7 @@ block tobject2:
block tofopr:
type
TMyType = object {.inheritable.}
TMyType {.inheritable.} = object
len: int
data: string

View File

@@ -23,12 +23,12 @@ struct SimpleStruct {
""" .}
type
GenericIntType {.importcpp: "GenericIntType<'0, '1>".} [N: static[int]; T] = object
GenericIntType[N: static[int]; T] {.importcpp: "GenericIntType<'0, '1>".} = object
data: array[N, T]
GenericIntTypeAlt {.importcpp: "GenericIntType".} [N: static[int]; T] = object
GenericIntTypeAlt[N: static[int]; T] {.importcpp: "GenericIntType".} = object
GenericTType {.importcpp: "GenericTType<'0>".} [T] = object
GenericTType[T] {.importcpp: "GenericTType<'0>".} = object
field: T
GenInt4 = GenericIntType[4, int]

View File

@@ -3,7 +3,7 @@
type
TRadixNodeKind = enum rnLinear, rnFull, rnLeaf
PRadixNode = ref TRadixNode
TRadixNode = object {.inheritable.}
TRadixNode {.inheritable.} = object
kind: TRadixNodeKind
TRadixNodeLinear = object of TRadixNode
len: int8

View File

@@ -1,5 +1,5 @@
type
TAnimal=object {.inheritable.}
TAnimal{.inheritable.}=object
PAnimal=ref TAnimal
TDog=object of TAnimal

View File

@@ -3,7 +3,7 @@ discard """
"""
type
TA = object {.pure, final.}
TA {.pure, final.} = object
x: string
var

View File

@@ -11,11 +11,11 @@ ob = T[int](elem: 23)
doAssert ob.elem == 23
type
TTreeIteratorA* = ref object {.inheritable.}
TTreeIteratorA* {.inheritable.} = ref object
TKeysIteratorA* = ref object of TTreeIteratorA #compiles
TTreeIterator* [T,D] = ref object {.inheritable.}
TTreeIterator* [T,D] {.inheritable.} = ref object
TKeysIterator* [T,D] = ref object of TTreeIterator[T,D] #this not

View File

@@ -0,0 +1,5 @@
discard """
errormsg: "invalid indentation"
"""
type Foo = object {.final.}

View File

@@ -0,0 +1,5 @@
discard """
errormsg: "invalid indentation"
"""
type Bar {.final.} [T] = object