Each mistake is a small change to day-to-day/src/morning.una, followed by what una check . reports. Read each diagnostic as If una check finds a mistake shows: the message, then the place, then the help.
[U0001]Error: invalid character `'`; text literals use double quotes╭─[ src/morning.una:51:11 ]
│51│section('Hours', notice: opening_hours())
│┬│╰── invalid character `'`; text literals use double quotes││Note: run `una explain U0001` for an explanation
────╯
Why: a text in Una is written between double quotes, ". A single quote, ', is not a character the language uses outside a text, so the check reports it, once for each quote: the two diagnostics point at columns 11 and 17 of the same line. Curly quotes, “ and ”, which some editors type in place of ", give the same code.
Fix: write "Hours", with the straight double quote of your keyboard. See U0001.
Start a comment with //, as some other languages do:
diff
--- a/src/morning.una+++ b/src/morning.una@@ -2,3 +2,3 @@--- The notices that the console of the store prints each morning, when the store opens.+// The notices that the console of the store prints each morning, when the store opens.
Diagnostic
[U0101]Error: unexpected `/`, expected a declaration
Why: in Una a comment starts with --. // is not a comment, so the check reads the line as code. Outside a function, a module holds only declarations, such as functions, so the check expected a declaration and found / instead. The marks point at the first /, in column 1.
Fix: write -- at the start of the comment. See U0101.
1.8.3 A public function that prints without uses (U3004)
Make rule public and write it on one line, without its uses line:
diff
--- a/src/morning.una+++ b/src/morning.una@@ -29,6 +29,3 @@
--- Prints a line of dashes, which separates the parts of the notices.
-rule() -> Unit- uses @console: Console[print]-=- @console.print("------------------------------")+pub rule() -> Unit = @console.print("------------------------------")
Diagnostic
[U3004]Error:`@console` is used here, but this code declares no `uses`, so it is pure╭─[ src/morning.una:30:22 ]
│30│pubrule() -> Unit = @console.print("------------------------------")
│────┬───│╰───── `@console` is used here, but this code declares no `uses`, so it is pure
Why: a public function without a uses line is pure: it may do nothing outside the program. Printing is something outside the program, so the marks point at @console, the use the header does not allow. The private rule of the program could leave the line out, but a public one cannot.
Fix: give the header its uses line back, uses @console: Console[print], with = and the body on lines of their own, or keep rule private. See U3004.
[U1008]Error: module `notices` is in `src/morning.una`, which must hold module `morning`
Why: the file src/morning.una must hold the module morning: una finds a module from its file, and a file from its module, so the two names must agree. A second diagnostic, U7002, follows: entry in una.toml names the module morning, which the package no longer has.
Fix: write module morning. To rename the module, rename the file and the entry in una.toml with it. See U1008.
[U0003]Error: inconsistent indentation of 4 spaces; expected 0 or 2╭─[ src/morning.una:39:1 ]
│39│@console.print(heading)
│──┬─│╰─── inconsistent indentation of 4 spaces; expected 0 or 2││ Help 1: repair 1: indent with 2 spaces; edit src/morning.una:39:1..39:5 to " "
││ Help 2: repair 2: remove the indentation; edit src/morning.una:39:1..39:5 to ""
Why: Una indents by two spaces, always: a body's steps by two, and nothing deeper in this chapter. A line indented by four belongs to no level the check knows, so it reports the line and offers two repairs, since it cannot tell which level you meant.
Fix: indent by two spaces, as the first repair says. Many code editors insert four spaces for the Tab key; set yours to two. See U0003.
[U2004]Error: argument 2 of `section` needs a label; only the first argument may go without one
Why: every argument after the first carries its parameter's name, so that a call says what each value is. Here the second argument, opening_hours(), is a call, not the name notice, so it is not labeled. The message names the argument by its place, 2, and the function, section.
Fix: write notice: opening_hours(), as the Help line of the diagnostic says, or let una fix . make that edit. See U2004.