Skip to content

Commit

Permalink
The check command controls the names of existing functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Schulz committed May 1, 2018
1 parent 8e56f86 commit 0544d88
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bin/lzt
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,8 @@ local function getfuncorder( funcinfos )
return flatten( groups )
end

local function goodname( ztree, name )
if ztree.fn[ name ] then
local function goodname( name, ztree )
if ztree and ztree.fn[ name ] then
errfln( "%q exists in module %q.", name, ztree.fn[ name ] )
return false
end
Expand Down Expand Up @@ -1162,6 +1162,10 @@ if cmd == "check" then
local problem = false
local graph = buildgraph( keys( funcinfos ), {} )
for fname, info in pairs( funcinfos ) do
if not goodname( info.mainfn.name ) then
return errexit()
end

for subfname, fn in pairs( info.fn ) do
if not fn.main then
local parentfunc = funcinfos[ subfname ]
Expand All @@ -1188,7 +1192,7 @@ elseif cmd == "checkname" then
errexit()
end

if not goodname( ztree, name ) then
if not goodname( name, ztree ) then
return errexit()
end

Expand Down Expand Up @@ -1233,7 +1237,7 @@ elseif cmd == "init" then
errfln( "init requires the parameter 'module'." )
errexit()
end
if not goodname( ztree, name ) then
if not goodname( name, ztree ) then
errexit()
end
if not ztree.mod[ mod ] then
Expand Down

0 comments on commit 0544d88

Please sign in to comment.