\r is accepted in unrestricted names and string literals without a nonstandard-notation warning, though KerML Table 4 does not list it (pilot grammar extension)

Aperta
#2,247 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go
Ambito
compilers

Direzione di ricerca

Start from source.IsEscapeChar, which decides which escape sequences the lexer accepts, and from the nonstandard-notation check in internal/check/passes/nonstandard_notation.go. Keep \r decoding as it is, and make the existing warning fire for \r in both unrestricted names and string literals, escalating under -validate -strict. Done when the false-positive scan over examples/ and the standard library stays silent.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Model and observed behaviour
package P {
    part def Pt;
    part 'cr\rx' : Pt;
    attribute s = "a\rb";
}

The model checks clean, under -validate -strict too: \r is accepted in an unrestricted name and in a string literal with no diagnostic, and is read as a carriage return (U+000D).

What the specification requires

KerML 1.1 Beta 2 §8.2.2.3, Note 2: "Table 4 shows the meaning of the allowed escape sequences." Table 4 (Escape Sequences) lists seven:

Escape Sequence Meaning
\' Single Quote
\" Double Quote
\b Backspace
\f Form Feed
\t Tab
\n Line Terminator
\\ Backslash

\r is not among them. §8.2.2.5 gives STRING_VALUE the same ESCAPE_SEQUENCE ("ESCAPE_SEQUENCE is specified in 8.2.2.3"), so the same holds for string literals.

Reference implementation

The pilot's grammar admits \r in both terminals (KerMLExpressions.xtext, pilot 2026-09):

terminal UNRESTRICTED_NAME returns Ecore::EString:
	'\'' ('\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | "'" | '\\') | !('\\' | '\''))* '\'';

terminal STRING_VALUE returns Ecore::EString:
	'"' ('\\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | "'" | '\\') | !('\\' | '"'))* '"';

and its exporter gives declaredName cr + U+000D + x for the name above. source.IsEscapeChar follows that grammar.

Proposed

Keep accepting and decoding \r, so what the pilot accepts still parses, and report it through the existing nonstandard-notation warning (internal/check/passes/nonstandard_notation.go) — in an unrestricted name and in a string literal alike, with the strict-conformance escalation that warning already has. The same applies to any other sequence the lexer admits beyond Table 4; today \r is the only one.

No file under examples/ (the downloaded corpora included) or the standard library writes \r in a name or a string, so the warning should be silent over them; the false-positive scan should confirm that.

Split out of #2241 (which fixes #2214, the decoding of escape sequences in names) to keep that change to its scope.

Kind of gap

Accepted beyond the specification without a diagnostic

Lingua principale
Go
Stelle
59
Fork
20
Merge medio
10h 23m
PR unite (30g)
897

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Open-MBEE/OpenSysML

Tutte le issue di Open-MBEE/OpenSysML

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.