\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)

Open
#2,247 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
compilers

Research direction

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.

Written by the indexing model from the issue text.

Description

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

Dominant language
Go
Stars
59
Forks
20
Avg merge
10h 23m
Merged PRs (30d)
897

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Open-MBEE/OpenSysML

All issues in Open-MBEE/OpenSysML

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.