Skip to content

Commit

Permalink
Upgrade to typed: true with let(false, Boolean)
Browse files Browse the repository at this point in the history
IMHO this is a design bug in Ruby copied into Sorbet.
A Boolean class should exist in Ruby, or Sorbet should infer it,
without us having to declare it with T.let

Without this:

```
./library/packages/src/modules/PackageKit.rb:52: Changing the type of a variable in a loop is not permitted https://srb.help/7001
    52 |        ret = true if Builtins.regexpmatch(line, "boolean.*true")
                      ^^^^
  Existing variable has type: FalseClass
  Attempting to change type to: TrueClass
```
  • Loading branch information
Martin Vidner committed Mar 29, 2021
1 parent 42d1a16 commit 542c96e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions library/packages/src/modules/PackageKit.rb
@@ -1,4 +1,4 @@
# typed: false
# typed: true
# ***************************************************************************
#
# Copyright (c) 2002 - 2012 Novell, Inc.
Expand Down Expand Up @@ -29,6 +29,7 @@
#
# This is a wrrapper around PackageKit DBus interface.
require "yast"
require "sorbet-runtime"

module Yast
class PackageKitClass < Module
Expand All @@ -43,7 +44,7 @@ def IsRunning

out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))

ret = false
ret = T.let(false, T::Boolean)
lines = Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n")

Builtins.foreach(lines) do |line|
Expand Down

0 comments on commit 542c96e

Please sign in to comment.