[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

parameter type is incorrectly reported by typeof()

From: Denis Shirokov
Subject: parameter type is incorrectly reported by typeof()
Date: Mon, 15 Nov 2021 22:33:48 +0200


found the following issue:

parameter type is incorrectly reported by typeof():

let's see on to example below:


      _a()        # define parameter as unassigned

      mode = 1

      print; print; print

      _a()        # define parameter as an array


func  _a( a ) {

      print "a: " typeof( a )

      _b( a )

      print "a: " typeof( a ) }

      func _b( b ) {

            _c( b )

            print "b: " typeof( b ) }

                  func  _c( c, x ) {

                        if ( mode )

                              "" in c

                        else  x = c

                        print "c: " typeof( c ) }


      D:\CPU\DEV\GAWK\REPORT\5\typeof>gawk -b -s -f ./typeof.gwk
      a: untyped
      c: untyped
      b: untyped
      a: unassigned

      a: untyped
      c: array
      b: array
      a: array

at the first time function _a() started the global var `mode' is false.
so it's will test type `unassigned' auto definition:

let's see on the results: at the enter of function _a() it's print the type
of parameter as `untyped'. then _a() calls _b() and it's call _c()
where parameter is forced to be unassigned. but the function _c() and _b()
reports that parameter is still untyped. at the exit function _a() printing
current type of parameter and it's correct: `unassigned'.

the problem is in that function _b() is still remains that type of the parameter
is `untyped' and even function _c() - where type definition is
performed it's still
report that parameter is `untyped'.

at the second time globvar `mode' is true so it's will test type `array'
it's seems that there is no problems here.

# GNU Awk 5.1.0, API: 3.0 (GNU MPFR 3.1.5, GNU MP 6.1.2)
# Windows 10 x64

Best Regards

reply via email to

[Prev in Thread] Current Thread [Next in Thread]