aboutsummaryrefslogtreecommitdiffhomepage
path: root/notes/goto_wo_fallthrough.txt
blob: b935087e5fdb27bd4155bb47e5bf044c69867e0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

goto without fallthrough?
=========================

A missing return/break/goto/etc can easilly cause incorrect behavior:

    func f() -> bool
    {
        do_stuff()
      err:                      #<--- missing "return true" before this line
        handle_error()
        return false
    }

Solution 1:

  err:            #<--- fall-through not allowed (except if first in a block)
    
    fallthrough
  err:            #<--- fall-through allowed

    unreachable
  err:            #<--- fall-through not possible