Tidy array validation flow

Agent-Logs-Url: https://github.com/wesleyel/swiftui-math/sessions/56436444-e15b-4dd0-8a70-c87df1e3dc4e

Co-authored-by: wesleyel <48174882+wesleyel@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-06 15:36:51 +00:00
committed by GitHub
parent 1091e9c83d
commit 77d6794b26
2 changed files with 8 additions and 4 deletions

View File

@@ -712,7 +712,7 @@ extension Math {
return table return table
} }
} else if env == "array" { } else if env == "array" {
guard let columnAlignments, !columnAlignments.isEmpty else { guard let columnAlignments else {
let message = "array environment requires at least 1 column alignment" let message = "array environment requires at least 1 column alignment"
if error == nil { if error == nil {
error = ParserError(code: .invalidEnvironment, message: message) error = ParserError(code: .invalidEnvironment, message: message)

View File

@@ -1332,18 +1332,22 @@ extension Math {
} }
} }
if self.error == nil && !foundClosingBrace { if !foundClosingBrace {
self.setError(.characterNotFound, message: "Missing } after array column format") self.setError(.characterNotFound, message: "Missing } after array column format")
} }
if self.error == nil && columnAlignments.isEmpty { if columnAlignments.isEmpty {
self.setError( self.setError(
.invalidEnvironment, .invalidEnvironment,
message: "array environment requires at least one column alignment specifier (l, c, or r)" message: "array environment requires at least one column alignment specifier (l, c, or r)"
) )
} }
return self.error == nil ? (columnAlignments, format) : (nil, nil) if self.error != nil {
return (nil, nil)
}
return (columnAlignments, format)
} }
func assertNotSpace(_ ch: Character) { func assertNotSpace(_ ch: Character) {