Just a guess, but try wrapping the return statement in parentheses - that is ... ? (return true) : .... I’ve found that most syntax errors I make can be solved with judicious use of parentheses.
I don’t understand it in detail, but it’s something to due with how the parser breaks down your code into expressions. Things like return and = for assignment are special - I’m guessing that stuff ? retun foo : bar gets parsed as (stuff) ? (return foo : bar) rather than what you intended (stuff) ? (return foo) : (bar)