diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f574b564835296081b7cfcade1d085527db0bd6..31b28cbbafd4fdcb5d3f7a67eddce6d279a8d0b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ## 0.1.3 -- feat(sema): coersion: numeric_literal -> float +- feat(sema): coercion: numeric_literal -> float - feat(sema): prevent passing non-runtime compatible types like `type` to opaque functions - feat(sema): properly validate and coerce binary operations - feat(sema): string concat with `+` @@ -25,7 +25,7 @@ ## 0.1.2 - feat: semantic analysis can return formatted errors to the user -- feat: implement basic type coersions +- feat: implement basic type coercions - feat: type-check call parameters - feat: type-check function return types - feat: parsing of assignments within expressions is disallowed now diff --git a/README.md b/README.md index 18bfe5fe6a62162dd60e3af7c2b187f332e3b8cc..c20ab9899951fb38287813d80615e9aa8c9b67f1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ For a guide on how to use the language, please see the Language Reference docume ## Building -The primary dependency of the language SDK is a Zig compiler. If one is not available, the `./build` and `.\build.cmd` scripts can subsitute for running `zig build` on POSIX and Windows systems, respectively. With a Zig compiler, a release build can be produced in a single command: +The primary dependency of the language SDK is a Zig compiler. If one is not available, the `./build` and `.\build.cmd` scripts can substitute for running `zig build` on POSIX and Windows systems, respectively. With a Zig compiler, a release build can be produced in a single command: zig build --release diff --git a/doc/language-manual.md b/doc/language-manual.md index 380e9e3ebbd04ec66124c94b6022bf63d607491c..6004e2c0b4a59004c45413fd53d7b7da5123e981 100644 --- a/doc/language-manual.md +++ b/doc/language-manual.md @@ -29,7 +29,7 @@ The `print` function is implemented by getting an external reference to the `con ## Primitive Data Types -| name | ts equivilent | description | +| name | ts equivalent | description | | ---------- | --------------------- | ---------------------------------------------- | | `int` | `number` | a number in signed 32-bit range | | `float` | `number` | a 64-bit floating point number | @@ -95,7 +95,7 @@ let message = if @js("Math").random() > 0.5 { @js("console").log(message); ``` -It should be noted that numeric literals are a comptime-only data type, meaning it cannot be assigned to a `var` without an explicit type annotation. Since `int` is a strict subset of valid `float`s, the coersion will implicitly be a float, but a compiler warning will be emitted. +It should be noted that numeric literals are a comptime-only data type, meaning it cannot be assigned to a `var` without an explicit type annotation. Since `int` is a strict subset of valid `float`s, the coercion will implicitly be a float, but a compiler warning will be emitted. ```lang var number = 0; // `number` is a `float`, but not explicit @@ -143,7 +143,7 @@ TODO ## JavaScript Interop -A global variable handle can be retrived with `@js`. We've seen this in the hello world. The type of this value is a special type called `opaque`, which disables type-checking. +A global variable handle can be retrieved with `@js`. We've seen this in the hello world. The type of this value is a special type called `opaque`, which disables type-checking. > **Note**: A future update will improve on the type-safety of `opaque` diff --git a/src/core/Parse.zig b/src/core/Parse.zig index b51bd54db921125f098edd8e7f27b78f9f95ce5b..d8d3b3449c150436798a0eda1e51f610fc077207 100644 --- a/src/core/Parse.zig +++ b/src/core/Parse.zig @@ -152,7 +152,7 @@ pub const AstError = union(enum) { }, "{s}", .{switch (data.err) { error.OutOfMemory => unreachable, error.InvalidSyntax => "unexpected token", - error.TrailingNumericSeparator => "trailing numberic separator", + error.TrailingNumericSeparator => "trailing numeric separator", error.UnterminatedString => "unterminated string literal", error.InvalidEscapeSequence => "invalid escape sequence", error.InvalidEscapeCodepoint => "invalid escape codepoint", diff --git a/src/core/Report.zig b/src/core/Report.zig index 183fc091721b3584c916d3c12472d5cc3d5424a6..9dbd664d962779b86ef2a77ff280f9f4fc3a358a 100644 --- a/src/core/Report.zig +++ b/src/core/Report.zig @@ -79,7 +79,7 @@ pub const Err = union(enum) { args: u32, fn build(data: @This(), ctx: *MsgContext) !void { - try ctx.msgNode(data.node, "built-in function expected {d} arguments, recieved {d}", .{ + try ctx.msgNode(data.node, "built-in function expected {d} arguments, received {d}", .{ data.args, ctx.ast.extraData(ctx.ast.nodeData(data.node).call.extra, Ast.Call).args.len, }); @@ -153,7 +153,7 @@ pub const Err = union(enum) { try ctx.msgNode(node, "numeric literal \"{d}\" cannot be coerced to \"int\"", .{data.val}); } }, - coersion: struct { + coercion: struct { from: Type, to: Type, src: LazyNode, @@ -184,7 +184,7 @@ pub const Err = union(enum) { fn build(data: @This(), ctx: *MsgContext) !void { const node = try data.call.get(ctx); - try ctx.msgNode(node, "function expected {d} arguments, recieved {d}", .{ + try ctx.msgNode(node, "function expected {d} arguments, received {d}", .{ data.expected, data.actual, }); diff --git a/src/core/Sema.zig b/src/core/Sema.zig index ab8102b819e9c5fb281849965719614a18810339..c2eccbe2c08f042077b14915da4e1bb9148b3a5e 100644 --- a/src/core/Sema.zig +++ b/src/core/Sema.zig @@ -718,7 +718,7 @@ fn coerceRef(s: *Sema, src: InstOp, value: Air.Inst.Ref, to: Type) !Air.Inst.Ref }, else => {}, } - return s.coersionError(src, from, to); + return s.coercionError(src, from, to); } fn coerceValue(s: *Sema, src: InstOp, value: Value, to: Type) !Value { @@ -755,7 +755,7 @@ fn coerceValue(s: *Sema, src: InstOp, value: Value, to: Type) !Value { }, else => unreachable, // not a numeric literal }, - else => return s.coersionError(src, from, to), + else => return s.coercionError(src, from, to), }, .float => switch (from) { .float => unreachable, // same type handled @@ -786,7 +786,7 @@ fn coerceValue(s: *Sema, src: InstOp, value: Value, to: Type) !Value { .void => if (value == .void) return .void, else => {}, } - return s.coersionError(src, from, to); + return s.coercionError(src, from, to); } fn ensureValueRuntime(s: *Sema, src: InstOp, ref: Air.Inst.Ref) !Air.Inst.Ref { @@ -1157,8 +1157,8 @@ fn fail(s: *Sema, comptime kind: Report.Err.FieldEnum, data: std.meta.FieldType( return Error.AnalysisFail; } -fn coersionError(s: *Sema, src: InstOp, from: Type, to: Type) Error { - return s.fail(.coersion, .{ +fn coercionError(s: *Sema, src: InstOp, from: Type, to: Type) Error { + return s.fail(.coercion, .{ .from = from, .to = to, .src = s.lazyNode(src), diff --git a/src/core/Teg.zig b/src/core/Teg.zig index 09518dbe73162df109a92476fa72be455d2798ac..e277b8711a21a19c5375f8d74076a199691f4600 100644 --- a/src/core/Teg.zig +++ b/src/core/Teg.zig @@ -24,7 +24,7 @@ pub const Inst = struct { block, /// Creates a memory cell in the current scope. memory, - /// Performs a type coersion, such as in variable declarations. + /// Performs a type coercion, such as in variable declarations. /// Emits a sema error if the type conversion fails. /// `let x: i32 = 1` as,