miniscript icon indicating copy to clipboard operation
miniscript copied to clipboard

Parsing errors in compiler: Missing an "else if" or "end if" in if-statement

Open GorgonRamsay opened this issue 5 years ago • 1 comments

Steps to Reproduce:

  1. Compile the following:
func = function()
  if false then
    return "This is returned"
  if true then
    return "This should be returned"
  end if
  return ""
end function

print(func)

Output: This is returned

Actual Results: Compilation was successful.

Expected Results: Compiler error, unmatched block opener.

Additional information:

  • The function is necessary for compilation to successfully fail.
  • Try without the function to see expected error.
  • The issue was observed in the game GreyHack.

GorgonRamsay avatar Apr 16 '20 15:04 GorgonRamsay

Confirmed. Thank you for the report.

JoeStrout avatar Apr 16 '20 23:04 JoeStrout

This is caused by end function just discarding function parsing context without checking for unclosed backpatches. Simplified "working" example for this issue:

func = function
  if 0 then
    print "this if is ignored"
end function
func

juh9870 avatar Dec 18 '22 21:12 juh9870