summary refs log tree commit diff stats
path: root/tests/objects/tobjconstr.nim
blob: ee5a5b2213a04e765bda56bf144624a51256aa20 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
discard """
  output: '''
(k: kindA, a: (x: "abc", z: @[1, 1, 3]), method: ())
(k: kindA, a: (x: "abc", z: @[1, 2, 3]), method: ())
(k: kindA, a: (x: "abc", z: @[1, 3, 3]), method: ())
(k: kindA, a: (x: "abc", z: @[1, 4, 3]), method: ())
(k: kindA, a: (x: "abc", z: @[1, 5, 3]), method: ())
(k: kindA, a: (x: "abc", z: @[1, 6, 3]), method: ())
(k: kindA, a: (x: "abc", z: @[1, 7, 3]), method: ())
(k: kindA, a: (x: "abc", z: @[1, 8, 3]), method: ())
(k: kindA, a: (x: "abc", z: @[1, 9, 3]), method: ())
(k: kindA, a: (x: "abc", z: @[1, 10, 3]), method: ())
(y: 0, x: 123)
(y: 678, x: 123)
(z: 89, y: 0, x: 128)
(y: 678, x: 123)
(y: 678, x: 123)
(y: 0, x: 123)
(y: 678, x: 123)
(y: 123, x: 678)
'''
"""

type
  TArg = object
    x: string
    z: seq[int]
  TKind = enum kindXY, kindA
  TEmpty = object
  TDummy = ref object
    case k: TKind
    of kindXY: x, y: int
    of kindA:
      a: TArg
      `method`: TEmpty # bug #1791

proc main() =
  for i in 1..10:
    let d = TDummy(k: kindA, a: TArg(x: "abc", z: @[1,i,3]), `method`: TEmpty())
    echo d[]

main()

# bug #6294
type
  A = object of RootObj
    x*: int
  B = object of A
    y*: int
  BS = object of B
  C = object of BS
    z*: int

proc main2 =
  # inherited fields are ignored, so no fields are set
  when true:
    var
      o: B
    o = B(x: 123)
    echo o
    o = B(y: 678, x: 123)
    echo o

  # inherited fields are ignored
  echo C(x: 128, z: 89)          # (y: 0, x: 0)
  echo B(y: 678, x: 123)  # (y: 678, x: 0)
  echo B(x: 123, y: 678)  # (y: 678, x: 0)

  when true:
    # correct, both with `var` and `let`;
    var b=B(x: 123)
    echo b                  # (y: 0, x: 123)
    b=B(y: 678, x: 123)
    echo b                  # (y: 678, x: 123)
    b=B(y: b.x, x: b.y)
    echo b                  # (y: 123, x: 678)

main2()
GC_fullCollect()
class="nt">sup class="footnote-ref" id="fnref-7"><a href="#fn-7">7</a></sup></p> <p>In Elsevier's case against Sci-Hub and Library Genesis, the judge said: <span class="quote">"simply making copyrighted content available for free via a foreign website, disserves the public interest"</span><sup class="footnote-ref" id="fnref-8"><a href="#fn-8">8</a></sup>. Alexandra Elbakyan's original plea put the stakes much higher: <span class="quote">"If Elsevier manages to shut down our projects or force them into the darknet, that will demonstrate an important idea: that the public does not have the right to knowledge."</span></p> <p>We demonstrate daily, and on a massive scale, that the system is broken. We share our writing secretly behind the backs of our publishers, circumvent paywalls to access articles and publications, digitize and upload books to libraries. This is the other side of 37% profit margins: our knowledge commons grows in the fault lines of a broken system. We are all custodians of knowledge, custodians of the same infrastructures that we depend on for producing knowledge, custodians of our fertile but fragile commons. To be a custodian is, de facto, to download, to share, to read, to write, to review, to edit, to digitize, to archive, to maintain libraries, to make them accessible. It is to be of use to, not to make property of, our knowledge commons.</p> <p>More than seven years ago Aaron Swartz, who spared no risk in standing up for what we here urge you to stand up for too, wrote: <span class="quote">"We need to take information, wherever it is stored, make our copies and share them with the world. We need to take stuff that's out of copyright and add it to the archive. We need to buy secret databases and put them on the Web. We need to download scientific journals and upload them to file sharing networks. We need to fight for Guerilla Open Access. With enough of us, around the world, we'll not just send a strong message opposing the privatization of knowledge — we'll make it a thing of the past. Will you join us?"</span><sup class="footnote-ref" id="fnref-9"><a href="#fn-9">9</a></sup></p> <p>We find ourselves at a decisive moment. This is the time to recognize that the very existence of our massive knowledge commons is an act of collective civil disobedience. It is the time to emerge from hiding and put our names behind this act of resistance. You may feel isolated, but there are many of us. The anger, desperation and fear of losing our library infrastructures, voiced across the internet, tell us that. This is the time for us custodians, being dogs, humans or cyborgs, with our names, nicknames and pseudonyms, to raise our voices.</p> <p class="share">Share this letter - read it in public - leave it in the printer. Share your writing - digitize a book - upload your files. Don't let our knowledge be crushed. Care for the libraries - care for the metadata - care for the backup. Water the flowers - clean the volcanoes.</p> <p class="date">30 November 2015</p> <p class="sig">Dušan Barok, Josephine Berry, Bodó Balázs, Sean Dockray, Kenneth Goldsmith, Anthony Iles, Lawrence Liang, Sebastian Lütgert, Pauline van Mourik Broekman, Marcell Mars, spideralex, Tomislav Medak, Dubravka Sekulić, Femke Snelting...</p> <hr> <div class="footnotes"> <ol> <li id="fn-1"> Larivière, Vincent, Stefanie Haustein, and Philippe Mongeon. “<a href="http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0127502">The Oligopoly of Academic Publishers in the Digital Era.</a>” PLoS ONE 10, no. 6 (June 10, 2015): e0127502. doi:10.1371/journal.pone.0127502., <br><a href="http://svpow.com/2012/01/13/the-obscene-profits-of-commercial-scholarly-publishers/">The Obscene Profits of Commercial Scholarly Publishers.</a>” svpow.com. Accessed November 30, 2015. &nbsp;<a href="#fnref-1" class="footnoteBackLink" title="Jump back to footnote 1 in the text."></a> </li> <li id="fn-2"> Sample, Ian. “<a href="http://www.theguardian.com/science/2012/apr/24/harvard-university-journal-publishers-prices">Harvard University Says It Can’t Afford Journal Publishers’ Prices.</a>” The Guardian, April 24, 2012, sec. Science. theguardian.com. &nbsp;<a href="#fnref-2" class="footnoteBackLink" title="Jump back to footnote 2 in the text."></a> </li> <li id="fn-3"><a href="http://www.aljazeera.com/indepth/opinion/2012/10/20121017558785551.html">Academic Paywalls Mean Publish and Perish - Al Jazeera English.</a>” Accessed November 30, 2015. aljazeera.com. &nbsp;<a href="#fnref-3" class="footnoteBackLink" title="Jump back to footnote 3 in the text."></a> </li> <li id="fn-4"><a href="https://torrentfreak.com/sci-hub-tears-down-academias-illegal-copyright-paywalls-150627/">Sci-Hub Tears Down Academia’s ‘Illegal’ Copyright Paywalls.</a>” TorrentFreak. Accessed November 30, 2015. torrentfreak.com. &nbsp;<a href="#fnref-4" class="footnoteBackLink" title="Jump back to footnote 4 in the text."></a> </li> <li id="fn-5"><a href="https://www.change.org/p/save-ashgate-publishing">Save Ashgate Publishing.</a>” Change.org. Accessed November 30, 2015. change.org. &nbsp;<a href="#fnref-5" class="footnoteBackLink" title="Jump back to footnote 5 in the text."></a> </li> <li id="fn-6"><a href="http://thecostofknowledge.com/">The Cost of Knowledge.</a>” Accessed November 30, 2015. thecostofknowledge.com. &nbsp;<a href="#fnref-6" class="footnoteBackLink" title="Jump back to footnote 6 in the text."></a> </li> <li id="fn-7"> <span class="foot-no-link">In fact, with the TPP and TTIP being rushed through the legislative process, no domain registrar, ISP provider, host or human rights organization will be able to prevent copyright industries and courts from criminalizing and shutting down websites "expeditiously". &nbsp;<a href="#fnref-7" class="footnoteBackLink" title="Jump back to footnote 7 in the text."></a></span> </li> <li id="fn-8"><a href="https://torrentfreak.com/court-orders-shutdown-of-libgen-bookfi-and-sci-hub-151102/">Court Orders Shutdown of Libgen, Bookfi and Sci-Hub.</a>” TorrentFreak. Accessed November 30, 2015. torrentfreak.com. &nbsp;<a href="#fnref-8" class="footnoteBackLink" title="Jump back to footnote 8 in the text."></a> </li> <li id="fn-9"><a href="https://archive.org/stream/GuerillaOpenAccessManifesto/Goamjuly2008_djvu.txt">Guerilla Open Access Manifesto.</a>” Internet Archive. Accessed November 30, 2015. archive.org. &nbsp;<a href="#fnref-9" class="footnoteBackLink" title="Jump back to footnote 9 in the text."></a> </li> </ol> </div> <div id="footer"> <hr /> <p><a href="/">Runxi Yu's Website</a></p> </div> </body> </html>