Skip to content

[Feat] diagnosis warn not allow if () line has Return / msgBoxΒ #84

@CoffeeChaton

Description

@CoffeeChaton

Feat Provide

πŸ”Ž Search keywords

diag
#34

πŸ’» Exp Code

#Warn All, MsgBox

fn(A_LineNumber, 1) ; b is 1
fn(A_LineNumber, 0) ; b is 1
fn(A_LineNumber, -1) ; b is 1

fn2(A_LineNumber, 1) ; b is 1
fn2(A_LineNumber, 0) ; b is 0
fn2(A_LineNumber, -1) ; b is 0

fn(user_LineNumber, c) {
    b := 0
    if (c>0) b := 1 ; TODO diag this case at ahk-v1 allow run this `b := 1` or auto format and add \n of this ?
        MsgBox, % "always run this line"
    MsgBox, % "b is " b " at ln " user_LineNumber
}

fn2(user_LineNumber, c) {
    b := 0
    if (c>0)
        b := 1 
    MsgBox, % "always run this line"
    MsgBox, % "b is " b " at ln " user_LineNumber
}
#Requires AutoHotkey v1.1.33+
; #Warn All, MsgBox

MsgBox, % foo(99) ; just 99 -> "caseEnd" , but not has "ELSE"
MsgBox, % foo(0) ; just "caseEnd", not "ELSE"
MsgBox, % foo(1) ; just "caseEnd", not "ELSE"
MsgBox, % foo(2) ; just "caseEnd", not "ELSE"
MsgBox, % foo(3) ; just "caseEnd", not "ELSE"
MsgBox, % foo(4) ; just "caseEnd", not "ELSE"

;@ahk-neko-format-ignore-start
foo(var1) {
    if (var1 = 99), Return "Case99"
        MsgBox, % "99"
    
    if (var1 = 0) , Return "caseA"
    if (var1 = 1) , Return "caseB"
    if (var1 = 2) , Return "caseC"
    if (var1 = 3) , Return "caseD"

    MsgBox, % "ELSE"
    Return "caseEnd"
}
;@ahk-neko-format-ignore-end
#Requires AutoHotkey v1.1.33+
; #Warn All, MsgBox

MsgBox, % foo(99) 
MsgBox, % foo(0) 
MsgBox, % foo(1) 
MsgBox, % foo(2) 
MsgBox, % foo(3)
MsgBox, % foo(4)

;@ahk-neko-format-ignore-start
foo(var1) {
    if (var1 = 99) Return "Case99"
        MsgBox, % "99"
    
    if (var1 = 0)  Return "caseA"
    if (var1 = 1)  Return "caseB"
    if (var1 = 2)  Return "caseC"
    if (var1 = 3)  Return "caseD"

    MsgBox, % "ELSE"
    Return "caseEnd"
}
;@ahk-neko-format-ignore-end

Additional context

i9

  1. Basic syntax errors , like this case
  2. complex logic with code

I want to focus on complex cases instead of being bothered by basic syntax errors.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions