Boo
  1. Boo
  2. BOO-418

Boo silently return null for method with return types without return statements

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Compiler
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The following code explicitly state that it's returning a value:

      def Foo() as string:
      str = "foo"

      Boo generate this code:

      def Foo() as string:
      str = "foo"
      return null

      For method the explicitly define their return type, a check should be made that all code paths are returning something.
      An error should be generated if that is not the case.

        Issue Links

          Activity

          Hide
          Rodrigo B. de Oliveira added a comment -

          By design.

          Show
          Rodrigo B. de Oliveira added a comment - By design.
          Hide
          Ayende Rahien added a comment -

          Even for a method where I explicitly want a return value?

          Can we get at least a warning: "You specified an explicit return value but no return value. Returning null" ?

          Show
          Ayende Rahien added a comment - Even for a method where I explicitly want a return value? Can we get at least a warning: "You specified an explicit return value but no return value. Returning null" ?
          Hide
          Rodrigo B. de Oliveira added a comment -

          I think it would be better to produce a lint pipeline which could be much more aggressive and detect lots of useful patterns.

          Show
          Rodrigo B. de Oliveira added a comment - I think it would be better to produce a lint pipeline which could be much more aggressive and detect lots of useful patterns.
          Hide
          Ayende Rahien added a comment -

          Agree!

          Show
          Ayende Rahien added a comment - Agree!

            People

            • Assignee:
              Unassigned
              Reporter:
              Ayende Rahien
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: