So. I was working with this code:

public function front(?string $sortBy,
        ?string $time,
        ?string $type,
        ?string $filter,
        string $federation,
        Request $request): Response
    {
        $user = $this->getUser();

        if (!$user)
        {
            $filter = 'all';
        }

        $criteria = new EntryPageView($this->getPageNb($request));
        $criteria->showSortOption($criteria->resolveSort($sortBy))    

… and so on; the function continues. VSCode told me there was a syntax error on the close brace on the if statement. I stared at it for a while, then pasted the code into GPT (not Copilot). Here’s the conversation we had about it:


Me

What’s the syntax error here?

(and I pasted the code)

GPT

The syntax error in your PHP function public function front seems to be due to the incorrect placement of the closing curly brace for the if statement. It appears that the if statement is not properly closed before the $criteria initialization begins. The corrected code should look like this:

public function front(?string $sortBy, ?string $time, ?string $type, ?string $filter, string $federation, Request $request): Response
{
    $user = $this->getUser();

    if (!$user) {
        $filter = 'all';
    } // Closing brace for the if statement

    $criteria = new EntryPageView($this->getPageNb($request));
    $criteria->showSortOption($criteria->resolveSort($sortBy));
    // ... rest of your function code ...
}

Ensure that each statement and block is properly closed and followed correctly by the next statement. This corrected structure should resolve the syntax error you are encountering.

Me

I don’t get it. I put a closing curly brace right after the statement in mine… what am I missing?

GPT

I apologize for the confusion. Upon re-examining your code, it seems the placement of the curly brace is correct. If you’re still encountering a syntax error, it may not be related to the if statement structure.

Let’s look at other possible issues:


… and so on. Pasting GPT’s recommended if-statement block, including the curly brace that was already there, fixed the error. I have since re-pasted the same thing I initially gave to GPT to VSCode, and it all works now, and asking the exact same question of GPT again now leads to random guesses which have nothing to do with the cursed curly brace that was previously causing problems for both VSCode and GPT.

I have given up and moved on at this point, content to say vaguely that maybe the unusual brace style, or pasting the incomplete function without semicolon or final close brace, managed to coincidentally confuse GPT on exactly the same line where VSCode had gotten confused for unexplained reasons. But the whole thing still has this Twilight-Zone oddness to me.

  • Moira_Mayhem@beehaw.org
    link
    fedilink
    arrow-up
    0
    ·
    9 months ago

    Fucking thank you. Everyone seems to think GPT is some kind of reasoning engine.

    It is just a storyteller with fucktastically huge pile of material to pull from.

    • mozz@mbin.grits.devOP
      link
      fedilink
      arrow-up
      0
      ·
      9 months ago

      Agree. It’s a matching and reshuffling engine. If you ask it a question the components of which are contained somewhere out in the universe of text it has to draw from, it’s able to find the answer in its data and reshuffle tokens around so that it can present that other person’s reasoned-out answers back to you in a way that they look like it reasoned them out itself.

      It’s incredibly impressive. That already is, as its successes are demonstrating, sufficient to execute a lot of “intelligence” tasks that previously computers just weren’t able to do. It’s still really easy to make it fall down by asking it questions that it can’t “reason” about by shuffling tokens around.

      Easy example:

      Me: How many asterisks in **4**3*****2**1**?

      GPT: The expression **4**3\*****2**1** contains a total of 10 asterisks.

      The random backslash was inserted by GPT. I’m presenting the question as typed, and the exact raw text GPT gave me back instead of the way it’s formatted by the web interface, escaping asterisks and backslashes both so that they appear in markdown exactly as they were in the raw input and output.