Trying to annotate this code, the rose memoization (@||=
) gives me an error Use of undeclared variable @git_sha
.
# typed: strict
# frozen_string_literal: true
module Util
extend T::Sig
sig { returns(String) }
def self.git_sha
@git_sha ||= ENV.fetch(
'GIT_REV',
`git rev-parse --verify HEAD 2>&1`
).chomp
end
end
As far as I've found, I should declare the variable's type with T.let
but haven't figured out specifically how.
strict
mode does not support ivars declared outside of a constructor. Changing the mode totrue
will make the error go away. – Leibniz