summary refs log tree commit diff stats
path: root/tests/controlflow/tunreachable.nim
blob: 06321ce8a9855eb772c1474704b6d63bc62b54a9 (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 """
  cmd: "nim check --warningAsError:UnreachableCode $file"
  action: "reject"
  nimout: '''
tunreachable.nim(26, 3) Error: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]
tunreachable.nim(33, 3) Error: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]
tunreachable.nim(42, 3) Error: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]
tunreachable.nim(65, 5) Error: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]
tunreachable.nim(77, 5) Error: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]
'''
"""
  
# bug #9839
template myquit1():untyped=
  ## foo
  quit(1)
template myquit2():untyped=
  echo 123
  myquit1()

proc main1()=

  # BUG: uncommenting this doesn't give `Error: unreachable statement`
  myquit2()

  echo "after"

main1()

proc main2() =
  myquit1()

  echo "after"

main2()

proc main3() =
  if true:
    return
  else:
    return
  echo "after"

main3()


block:
  # Cases like strings are not checked for exhaustiveness unless they have an else
  proc main4(x: string) =
    case x
    of "a":
      return
    # reachable
    echo "after"

  main4("a")

  proc main5(x: string) =
    case x
    of "a":
      return
    else:
      return
    # unreachable
    echo "after"

  main5("a")

block:
  # In this case no else is needed because it's exhaustive
  proc exhaustive(x: bool) =
    case x
    of true:
      return
    of false:
      return
    echo "after"

  exhaustive(true)
span>dt> <dd>Removes/uninstalls a previously installed software packages.</dd> <dt>prt-get(8)</dt> <dd>prt-get is a package management tool which provides additional functionality to crux' package management system. It works with the local ports tree and is therefore fully compatible with ports(8) and pkgmk(8)/pkgadd(8)</dd> </dl> <p>Test configuration by runing prt-get as admin user installing ports that are related;</p> <pre> $ prt-get depinst prt-utils prt-get-bashcompletion </pre> <h2 id="sysup">2.4.1. Update System</h2> <p>Before build software get latest version of port collections;</p> <pre> $ sudo ports -u </pre> <p>When coming from install or there is to much updates, I prefer to update gcc, glibc, libtool and binutils before doing a sysup;</p> <pre> $ prt-get update gcc $ prt-get update glibc $ prt-get update libtool $ prt-get update binutils </pre> <p>Build and install updated versions of ports;</p> <pre> $ prt-get sysup </pre> <p>Rebuild any revision dependency;</p> <pre> $ prt-get update -fr $(revdep) </pre> <h2 id="depinst">2.4.2. Install port and dependencies</h2> <p>Installing using prt-get tool;</p> <pre> $ prt-get depinst git </pre> <p>Installing using pkgmk and pkgadd, first build the package;</p> <pre> $ cd /usr/ports/opt/git $ sudo -H -u pkgmk fakeroot pkgmk -d </pre> <p>Install the package;</p> <pre> $ sudo pkgadd /usr/ports/packages/git#2.9.3-1.pkg.tar.gz </pre> <p>If you user pkgmk and pkgadd allways check if README, pre and post instal files exist.</p> <h3 id="ports">2.4.3. Ports collections</h3> <p>Clone this documentation;</p> <pre> $ git clone https://github.com/s1lvino/c9-doc.git </pre> <p>Install collections later documented;</p> <pre> $ sudo cp c9-doc/core/conf/ports/* /etc/ports/ </pre> <p>Edit /etc/prt-get.conf to activate new collections;</p> <pre> # the following line enables the user maintained contrib collection prtdir /usr/ports/contrib # ports described on this documentation prtdir /usr/ports/c9-ports # 6c37 team provides a collection with freetype-iu, fontconfig-iu # and cairo-iu ports. prtdir /usr/ports/6c37-dropin prtdir /usr/ports/6c37 </pre> <p>Get new ports;</p> <pre> $ sudo ports -u c9-ports $ sudo ports -u 6c37-dropin $ sudo ports -u 6c37 </pre> <h2 id="info">2.4.4. Show port information</h2> <pre> $ prt-get info port_name </pre> <p>List files port install into system;</p> <pre> $ pkginfo -l package_name </pre> <p>Discover to wich port a file belongs;</p> <pre> $ pkginfo -o filename </pre> <h2 id="depends">2.4.5. Show port dependencies</h2> <pre> $ prt-get depends port_name </pre> <h2 id="printf">2.4.6. Print information</h2> <p>Example how to get ports installed from contrib. Maybe there is a "cleaner" way to this, for now is ok;</p> <pre> prt-get printf "%p %i %n %v\n" | grep "/usr/ports/contrib yes" </pre> <a href="index.html">Core OS Index</a> <p>This is part of the c9-doc Manual. Copyright (C) 2017 c9 team. See the file <a href="../fdl-1.3-standalone.html">Gnu Free Documentation License</a> for copying conditions.</p> </body> </html>