Commits

ZyX_I  committed eb10722

Improved isfunc check: it now forbids function names starting with s:

  • Participants
  • Parent commits 515b91a

Comments (0)

Files changed (3)

File plugin/frawor/fwc/compiler.vim

                 " TODO
             elseif desc[0] is 'isfunc'
                 let addedcond=1
+                let frefpref='string('.curargstr.')[10:11]'
                 if desc[1]
                     call self.addtypecond([2], idx)
-                    call self.nextcond('!exists('.string('*'.curargstr).')')
+                    call self.nextcond('!exists('.string('*'.curargstr).') || '.
+                                \      frefpref.' is "s:"')
                                 \.addthrow('nfunc', idx, '@#@',
                                 \          'string('.curargstr.')[10:-3]')
                                 \.up()
                 else
                     call self.nextcond('!((type('.curargstr.')==2 && '.
-                                \         'exists('.string('*'.curargstr).')) '.
+                                \         'exists('.string('*'.curargstr).')&&'.
+                                \          frefpref.' isnot "s:") '.
                                 \        '|| (type('.curargstr.')=='.type("").
-                                \            '&& exists("*".'.curargstr.')))')
+                                \            '&& exists("*".'.curargstr.'))'.
+                                \            '&& '.curargstr.'[:1] isnot "s:")')
                                 \.addthrow('nsfunc', idx, '@#@',
                                 \                    'string('.curargstr.')')
                                 \.up()

File test/fwccheck.ok

 ::: Section <Checks/Built-in checks>
 plugin/frawor/fwc/compiler:funcfail
 plugin/frawor/fwc/compiler:exprfail
-plugin/frawor/fwc/compiler:nsfunc
-plugin/frawor/fwc/compiler:typefail
 plugin/frawor/fwc/compiler:nbool
 plugin/frawor/fwc/compiler:nbool
 plugin/frawor/fwc/compiler:typefail
 plugin/frawor/fwc/compiler:nreg
+::: Section <Checks/isfunc>
+plugin/frawor/fwc/compiler:nsfunc
+plugin/frawor/fwc/compiler:nsfunc
+plugin/frawor/fwc/compiler:typefail
+plugin/frawor/fwc/compiler:nfunc
+::: Section <Checks/isfunc/Match>
 plugin/frawor/fwc/compiler:nmatch
 plugin/frawor/fwc/compiler:typefail
 plugin/frawor/fwc/compiler:nmatch
-::: Section <Checks/Built-in checks/Types>
+::: Section <Checks/isfunc/Types>
 plugin/frawor/fwc/compiler:typefail
 plugin/frawor/fwc/compiler:typefail
 plugin/frawor/fwc/compiler:typefail

File test/fwctests.dat

 ['func ordered',    'check'], ['acb'],              0
 ['eval empty(@.@)', 'check'], ['abc'],              0
 ['eval empty(@.@)', 'check'], [''],                 1
-['isfunc',          'check'], [function("tr")],     1
-['isfunc',          'check'], [function("s:Eval")], 0
-['isfunc',          'check'], ["tr"],               1
-['isfunc 1',        'check'], ["tr"],               0
 ['bool',            'check'], [""],                 0
 ['bool',            'check'], [0],                  1
 ['bool',            'check'], [1],                  1
 ['isreg',           'check'], ['\(abc'],            0
 ['_',               'check'], [[[[]]]],             1
 ['any',             'check'], [[[[]]]],             1
+#▶2 isfunc
+['isfunc',          'check'], [function("tr")],     1
+['isfunc',          'check'], [function("s:Eval")], 0
+['isfunc',          'check'], ["tr"],               1
+['isfunc',          'check'], ["s:Eval"],           0
+['isfunc 1',        'check'], ["tr"],               0
+['isfunc 1',        'check'], [function("s:Eval")], 0
+#▶3 Match
 ['match/\vb@<!a/',  'check'], ['abc'],              1
 ['match/\vb@<!a/',  'check'], ['bac'],              0
 ['match/\vb@<!a/',  'check'], [0],                  0