• Skull giver@popplesburger.hilciferous.nl
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    1 year ago

    IntelliJ has a setting like that, it’ll auto correct/lint/format files on save. Super useful, except sometimes when it’ll fuck up your entire file because it placed a bracket at the wrong place.

    I’ve had it do that at some point when I forgot a semicolon in Javascript at exactly the wrong position. You see, Javascript can work without semicolons and it’ll automatically add them for you, except in a few cases where you need to be explicit.

    For example:

    const mishmash = 13 + 'world'
    
    [13].length
    

    This will place the semicolon after the .length, turning the code into const mishmash = 13 + 'world'[13].length.

    In my case, it tried to be smart about inserting a semicolon in an unexpected case, and it turned nested .map() call into something completely unexpected while I hit ctrl+a on unfinished code. Took me a git reset to get something readable out of the that file again!

    As for Rust: using some macros tends to make it suggest baffling syntax alterations sometimes. When you fuck up a macro in such a way that the macro no longer generates correct syntax, you can get the Rust compiler to suggest placing semicolons halfway through statements or even words.

    • drcobaltjedi@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      See, it’s this trying to be overly friendly nonsense I hate about JS. If you need semicolons, demand them. Don’t make it seem like you don’t then make your code break because it hudes that you do. My first orogramming job was at large multinational japanese motor company and they had a hard rule over no in house exe’s or opensource software. So the compromise was doing everything in JS. JS refused to listen to me on doing a single threaded for loop, just run the loop, wait a moment, run the next one, wait a moment…

      JS, don’t help me, just do as I say