File tree Expand file tree Collapse file tree 4 files changed +26
-5
lines changed
Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ local type = type
5757--- @field step parser.object
5858--- @field redundant { max : integer , passed : integer }
5959--- @field filter parser.object
60+ --- @field hasGoTo ? true
61+ --- @field hasReturn ? true
6062--- @field _root parser.object
6163
6264--- @class guide
@@ -416,6 +418,7 @@ function m.getUri(obj)
416418 return ' '
417419end
418420
421+ --- @return parser.object
419422function m .getENV (source , start )
420423 if not start then
421424 start = 1
Original file line number Diff line number Diff line change @@ -2963,10 +2963,7 @@ local function parseReturn()
29632963 if block .type == ' ifblock'
29642964 or block .type == ' elseifblock'
29652965 or block .type == ' else' then
2966- if not block .returns then
2967- block .returns = {}
2968- end
2969- block .returns [# block .returns + 1 ] = rtn
2966+ block .hasReturn = true
29702967 break
29712968 end
29722969 end
@@ -3066,6 +3063,15 @@ local function parseGoTo()
30663063 break
30673064 end
30683065 end
3066+ for i = # Chunk , 1 , - 1 do
3067+ local chunk = Chunk [i ]
3068+ if chunk .type == ' ifblock'
3069+ or chunk .type == ' elseifblock'
3070+ or chunk .type == ' elseblock' then
3071+ chunk .hasGoTo = true
3072+ break
3073+ end
3074+ end
30693075
30703076 pushActionIntoCurrentChunk (action )
30713077 return action
Original file line number Diff line number Diff line change @@ -192,7 +192,8 @@ function mt:_compileBlock(block)
192192 }
193193 self .steps [# self .steps + 1 ] = blockStep
194194 self :_compileNarrowByFilter (childBlock .filter , outStep , blockStep )
195- if not childBlock .returns then
195+ if not childBlock .hasReturn
196+ and not childBlock .hasGoTo then
196197 finals [# finals + 1 ] = blockStep
197198 end
198199 self .steps [# self .steps + 1 ] = {
Original file line number Diff line number Diff line change @@ -1855,6 +1855,17 @@ end
18551855print(<?x?>)
18561856]]
18571857
1858+ TEST ' integer' [[
1859+ ---@type integer?
1860+ local x
1861+
1862+ if not x then
1863+ goto ANYWHERE
1864+ end
1865+
1866+ print(<?x?>)
1867+ ]]
1868+
18581869TEST ' integer' [=[
18591870local x
18601871
You can’t perform that action at this time.
0 commit comments