moonbit-docs icon indicating copy to clipboard operation
moonbit-docs copied to clipboard

Bug: In VSCode plugin, the guard syntax cannot step over through code line by line when in debug mode.

Open Seedking opened this issue 11 months ago • 4 comments

fn validate_semver(semver : String) -> Bool {
  guard semver.length() != 0 else { return false }
  guard check_chars_is_valid(semver) else { return false }
  guard check_symbols_in_limit(semver) else { return false }
  guard check_dots_not_consecutive(semver) else { return false }
  guard check_neg_pos_symbols_is_order(semver) else { return false }
  guard check_split_part_is_valide(semver) else { return false }
  true
}

If the breakpoint is on the guard semver.length() != 0 else { return false }, using step over execution will directly jump to the true.

Seedking avatar Mar 24 '25 03:03 Seedking

Thank you for reporting. I'm going to address it next week.

hackwaly avatar Mar 27 '25 08:03 hackwaly

Thank you for reporting. I'm going to address it next week.

https://github.com/Seedking/SemVer you can directly test this bug in my project

Seedking avatar Mar 27 '25 08:03 Seedking

It looks like the guard chain is compiled to ternary expression chain. So step over not works. This might not easy to fix, but there's a workaround:

You can use "> Disable Source Mapped Stepping" command in vscode, to degrade to javascript source debugging, at this view you can add inline/column breakpoints.

function Seedking$SemVer$$validate_semver(semver) {
  return semver.length !== 0 ? (Seedking$SemVer$$check_chars_is_valid(semver) ? (Seedking$SemVer$$check_symbols_in_limit(semver) ? (Seedking$SemVer$$check_dots_not_consecutive(semver) ? (Seedking$SemVer$$check_neg_pos_symbols_is_order(semver) ? Seedking$SemVer$$check_split_part_is_valide(semver) : false) : false) : false) : false) : false;
}

hackwaly avatar Apr 01 '25 03:04 hackwaly

It looks like the guard chain is compiled to ternary expression chain. So step over not works. This might not easy to fix, but there's a workaround:

You can use "> Disable Source Mapped Stepping" command in vscode, to degrade to javascript source debugging, at this view you can add inline/column breakpoints.

function Seedking$SemVer$$validate_semver(semver) {
  return semver.length !== 0 ? (Seedking$SemVer$$check_chars_is_valid(semver) ? (Seedking$SemVer$$check_symbols_in_limit(semver) ? (Seedking$SemVer$$check_dots_not_consecutive(semver) ? (Seedking$SemVer$$check_neg_pos_symbols_is_order(semver) ? Seedking$SemVer$$check_split_part_is_valide(semver) : false) : false) : false) : false) : false;
}

thank you, i'll try this

Seedking avatar Apr 01 '25 04:04 Seedking