implement: unit identity -- dotted paths, name rules, source path
Units start here, with the part that needs no import graph: what a unit is called and where it must live. The parser only ever read a single identifier after `unit` and `import`, so `unit game.main;` and `import std.io;` were syntax errors -- which is why the dotted fixtures failed at the semicolon. It now reads a dotted path and stores it canonically, dots included, since that spelling is the unit's identity everywhere else. `import a.b as c;` parses too, with the alias on the node. resolve.c is the new pass between parsing and checking, for the questions that span files. It carries SPEC 8.1 so far: each path segment is ASCII lowercase, starts with a letter, continues with letters, digits or underscore, and is at most eight characters; and the dotted path must match the source path it was read from, so game.world.map has to come from game/world/map.fe. The source side is folded to lowercase before comparing, because a case-insensitive host must not let two spellings become two units. That rule then applied to the fixtures, which were not obeying it: 57 declared a unit name unrelated to their file, left over from the milestone directories, and eight had names too long to be legal. Both are now aligned -- the rule is worth having only if the tree follows it. units: badupper, badlong and unitbad pass. 138 -> 146 of 188. The rest of units/ needs the import graph, which is the next piece: resolution, cycles, bindings and visibility.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
unit m4_bad_arity;
|
||||
unit bad_ari;
|
||||
|
||||
fn main() -> i32 {
|
||||
@print("{} {}", 1);
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_bad_buffer_writer;
|
||||
unit bad_bufw;
|
||||
|
||||
fn main() -> void {
|
||||
var raw: [4]u8 = [0, 0, 0, 0];
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_bad_cls;
|
||||
unit bad_cls;
|
||||
|
||||
fn main() -> i32 {
|
||||
@print("}", 1);
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_bad_many;
|
||||
unit bad_many;
|
||||
|
||||
fn main() -> i32 {
|
||||
@print("{}", 1, 2);
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_bad_open;
|
||||
unit bad_open;
|
||||
|
||||
fn main() -> i32 {
|
||||
@print("{", 1);
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_bad_runtime;
|
||||
unit bad_run;
|
||||
|
||||
fn main() -> i32 {
|
||||
var fmt: str = "{}";
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_bad_try;
|
||||
unit bad_try;
|
||||
|
||||
fn main() -> i32 {
|
||||
try @print("nope");
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_bad_type;
|
||||
unit bad_type;
|
||||
|
||||
struct Point { x: i32, }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_bad_verb;
|
||||
unit bad_verb;
|
||||
|
||||
fn main() -> i32 {
|
||||
@print("{q}", 1);
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_bad_writer;
|
||||
unit bad_writ;
|
||||
|
||||
fn main() -> i32 {
|
||||
var x: i32 = 0;
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_format;
|
||||
unit ok_forma;
|
||||
|
||||
const FMT: str = "n={} hex={x} c={c} s={s} b={b} {{ok}}\n";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_prop;
|
||||
unit ok_prop;
|
||||
|
||||
pub fn propagate(w: io.Writer) -> !void {
|
||||
try @fprint(w, "a{}b", 1);
|
||||
@@ -1,4 +1,4 @@
|
||||
unit m4_try_fprint;
|
||||
unit ok_try_f;
|
||||
|
||||
fn main() -> !void {
|
||||
var raw: [4]u8 = [0, 0, 0, 0];
|
||||
Reference in New Issue
Block a user