| author | |
| committer | |
| log | 8b935ce08d481f23b4801f4b6440eaa5480eb70f |
| tree | 5b5717b10dd10fb791cbef0666bde62f245b0734 |
| parent | 84a6254c0de7dd1bcd097da3898d2b4cb8c4b64e |
| signature | Commit is signed but in an unrecognized format. |
7 files changed, 16 insertions(+), 16 deletions(-)
CHANGELOG.md+2-2| ... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | ||
| 7 | ## 0.1.3 | 7 | ## 0.1.3 |
| 8 | 8 | ||
| 9 | - feat(sema): coersion: numeric_literal -> float | 9 | - feat(sema): coercion: numeric_literal -> float |
| 10 | - feat(sema): prevent passing non-runtime compatible types like `type` to opaque functions | 10 | - feat(sema): prevent passing non-runtime compatible types like `type` to opaque functions |
| 11 | - feat(sema): properly validate and coerce binary operations | 11 | - feat(sema): properly validate and coerce binary operations |
| 12 | - feat(sema): string concat with `+` | 12 | - feat(sema): string concat with `+` |
| ... | @@ -25,7 +25,7 @@ | ... | @@ -25,7 +25,7 @@ |
| 25 | ## 0.1.2 | 25 | ## 0.1.2 |
| 26 | 26 | ||
| 27 | - feat: semantic analysis can return formatted errors to the user | 27 | - feat: semantic analysis can return formatted errors to the user |
| 28 | - feat: implement basic type coersions | 28 | - feat: implement basic type coercions |
| 29 | - feat: type-check call parameters | 29 | - feat: type-check call parameters |
| 30 | - feat: type-check function return types | 30 | - feat: type-check function return types |
| 31 | - feat: parsing of assignments within expressions is disallowed now | 31 | - feat: parsing of assignments within expressions is disallowed now |
README.md+1-1| ... | @@ -6,7 +6,7 @@ For a guide on how to use the language, please see the Language Reference docume | ... | @@ -6,7 +6,7 @@ For a guide on how to use the language, please see the Language Reference docume |
| 6 | 6 | ||
| 7 | ## Building | 7 | ## Building |
| 8 | 8 | ||
| 9 | 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: | 9 | 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: |
| 10 | 10 | ||
| 11 | zig build --release | 11 | zig build --release |
| 12 | 12 |
doc/language-manual.md+3-3| ... | @@ -29,7 +29,7 @@ The `print` function is implemented by getting an external reference to the `con | ... | @@ -29,7 +29,7 @@ The `print` function is implemented by getting an external reference to the `con |
| 29 | 29 | ||
| 30 | ## Primitive Data Types | 30 | ## Primitive Data Types |
| 31 | 31 | ||
| 32 | | name | ts equivilent | description | | 32 | | name | ts equivalent | description | |
| 33 | | ---------- | --------------------- | ---------------------------------------------- | | 33 | | ---------- | --------------------- | ---------------------------------------------- | |
| 34 | | `int` | `number` | a number in signed 32-bit range | | 34 | | `int` | `number` | a number in signed 32-bit range | |
| 35 | | `float` | `number` | a 64-bit floating point number | | 35 | | `float` | `number` | a 64-bit floating point number | |
| ... | @@ -95,7 +95,7 @@ let message = if @js("Math").random() > 0.5 { | ... | @@ -95,7 +95,7 @@ let message = if @js("Math").random() > 0.5 { |
| 95 | @js("console").log(message); | 95 | @js("console").log(message); |
| 96 | ``` | 96 | ``` |
| 97 | 97 | ||
| 98 | 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. | 98 | 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. |
| 99 | 99 | ||
| 100 | ```lang | 100 | ```lang |
| 101 | var number = 0; // `number` is a `float`, but not explicit | 101 | var number = 0; // `number` is a `float`, but not explicit |
| ... | @@ -143,7 +143,7 @@ TODO | ... | @@ -143,7 +143,7 @@ TODO |
| 143 | 143 | ||
| 144 | ## JavaScript Interop | 144 | ## JavaScript Interop |
| 145 | 145 | ||
| 146 | 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. | 146 | 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. |
| 147 | 147 | ||
| 148 | > **Note**: A future update will improve on the type-safety of `opaque` | 148 | > **Note**: A future update will improve on the type-safety of `opaque` |
| 149 | 149 |
src/core/Parse.zig+1-1| ... | @@ -152,7 +152,7 @@ pub const AstError = union(enum) { | ... | @@ -152,7 +152,7 @@ pub const AstError = union(enum) { |
| 152 | }, "{s}", .{switch (data.err) { | 152 | }, "{s}", .{switch (data.err) { |
| 153 | error.OutOfMemory => unreachable, | 153 | error.OutOfMemory => unreachable, |
| 154 | error.InvalidSyntax => "unexpected token", | 154 | error.InvalidSyntax => "unexpected token", |
| 155 | error.TrailingNumericSeparator => "trailing numberic separator", | 155 | error.TrailingNumericSeparator => "trailing numeric separator", |
| 156 | error.UnterminatedString => "unterminated string literal", | 156 | error.UnterminatedString => "unterminated string literal", |
| 157 | error.InvalidEscapeSequence => "invalid escape sequence", | 157 | error.InvalidEscapeSequence => "invalid escape sequence", |
| 158 | error.InvalidEscapeCodepoint => "invalid escape codepoint", | 158 | error.InvalidEscapeCodepoint => "invalid escape codepoint", |
src/core/Report.zig+3-3| ... | @@ -79,7 +79,7 @@ pub const Err = union(enum) { | ... | @@ -79,7 +79,7 @@ pub const Err = union(enum) { |
| 79 | args: u32, | 79 | args: u32, |
| 80 | 80 | ||
| 81 | fn build(data: @This(), ctx: *MsgContext) !void { | 81 | fn build(data: @This(), ctx: *MsgContext) !void { |
| 82 | try ctx.msgNode(data.node, "built-in function expected {d} arguments, recieved {d}", .{ | 82 | try ctx.msgNode(data.node, "built-in function expected {d} arguments, received {d}", .{ |
| 83 | data.args, | 83 | data.args, |
| 84 | ctx.ast.extraData(ctx.ast.nodeData(data.node).call.extra, Ast.Call).args.len, | 84 | ctx.ast.extraData(ctx.ast.nodeData(data.node).call.extra, Ast.Call).args.len, |
| 85 | }); | 85 | }); |
| ... | @@ -153,7 +153,7 @@ pub const Err = union(enum) { | ... | @@ -153,7 +153,7 @@ pub const Err = union(enum) { |
| 153 | try ctx.msgNode(node, "numeric literal \"{d}\" cannot be coerced to \"int\"", .{data.val}); | 153 | try ctx.msgNode(node, "numeric literal \"{d}\" cannot be coerced to \"int\"", .{data.val}); |
| 154 | } | 154 | } |
| 155 | }, | 155 | }, |
| 156 | coersion: struct { | 156 | coercion: struct { |
| 157 | from: Type, | 157 | from: Type, |
| 158 | to: Type, | 158 | to: Type, |
| 159 | src: LazyNode, | 159 | src: LazyNode, |
| ... | @@ -184,7 +184,7 @@ pub const Err = union(enum) { | ... | @@ -184,7 +184,7 @@ pub const Err = union(enum) { |
| 184 | 184 | ||
| 185 | fn build(data: @This(), ctx: *MsgContext) !void { | 185 | fn build(data: @This(), ctx: *MsgContext) !void { |
| 186 | const node = try data.call.get(ctx); | 186 | const node = try data.call.get(ctx); |
| 187 | try ctx.msgNode(node, "function expected {d} arguments, recieved {d}", .{ | 187 | try ctx.msgNode(node, "function expected {d} arguments, received {d}", .{ |
| 188 | data.expected, | 188 | data.expected, |
| 189 | data.actual, | 189 | data.actual, |
| 190 | }); | 190 | }); |
src/core/Sema.zig+5-5| ... | @@ -718,7 +718,7 @@ fn coerceRef(s: *Sema, src: InstOp, value: Air.Inst.Ref, to: Type) !Air.Inst.Ref | ... | @@ -718,7 +718,7 @@ fn coerceRef(s: *Sema, src: InstOp, value: Air.Inst.Ref, to: Type) !Air.Inst.Ref |
| 718 | }, | 718 | }, |
| 719 | else => {}, | 719 | else => {}, |
| 720 | } | 720 | } |
| 721 | return s.coersionError(src, from, to); | 721 | return s.coercionError(src, from, to); |
| 722 | } | 722 | } |
| 723 | 723 | ||
| 724 | fn coerceValue(s: *Sema, src: InstOp, value: Value, to: Type) !Value { | 724 | 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 { | ... | @@ -755,7 +755,7 @@ fn coerceValue(s: *Sema, src: InstOp, value: Value, to: Type) !Value { |
| 755 | }, | 755 | }, |
| 756 | else => unreachable, // not a numeric literal | 756 | else => unreachable, // not a numeric literal |
| 757 | }, | 757 | }, |
| 758 | else => return s.coersionError(src, from, to), | 758 | else => return s.coercionError(src, from, to), |
| 759 | }, | 759 | }, |
| 760 | .float => switch (from) { | 760 | .float => switch (from) { |
| 761 | .float => unreachable, // same type handled | 761 | .float => unreachable, // same type handled |
| ... | @@ -786,7 +786,7 @@ fn coerceValue(s: *Sema, src: InstOp, value: Value, to: Type) !Value { | ... | @@ -786,7 +786,7 @@ fn coerceValue(s: *Sema, src: InstOp, value: Value, to: Type) !Value { |
| 786 | .void => if (value == .void) return .void, | 786 | .void => if (value == .void) return .void, |
| 787 | else => {}, | 787 | else => {}, |
| 788 | } | 788 | } |
| 789 | return s.coersionError(src, from, to); | 789 | return s.coercionError(src, from, to); |
| 790 | } | 790 | } |
| 791 | 791 | ||
| 792 | fn ensureValueRuntime(s: *Sema, src: InstOp, ref: Air.Inst.Ref) !Air.Inst.Ref { | 792 | 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( | ... | @@ -1157,8 +1157,8 @@ fn fail(s: *Sema, comptime kind: Report.Err.FieldEnum, data: std.meta.FieldType( |
| 1157 | return Error.AnalysisFail; | 1157 | return Error.AnalysisFail; |
| 1158 | } | 1158 | } |
| 1159 | 1159 | ||
| 1160 | fn coersionError(s: *Sema, src: InstOp, from: Type, to: Type) Error { | 1160 | fn coercionError(s: *Sema, src: InstOp, from: Type, to: Type) Error { |
| 1161 | return s.fail(.coersion, .{ | 1161 | return s.fail(.coercion, .{ |
| 1162 | .from = from, | 1162 | .from = from, |
| 1163 | .to = to, | 1163 | .to = to, |
| 1164 | .src = s.lazyNode(src), | 1164 | .src = s.lazyNode(src), |
src/core/Teg.zig+1-1| ... | @@ -24,7 +24,7 @@ pub const Inst = struct { | ... | @@ -24,7 +24,7 @@ pub const Inst = struct { |
| 24 | block, | 24 | block, |
| 25 | /// Creates a memory cell in the current scope. | 25 | /// Creates a memory cell in the current scope. |
| 26 | memory, | 26 | memory, |
| 27 | /// Performs a type coersion, such as in variable declarations. | 27 | /// Performs a type coercion, such as in variable declarations. |
| 28 | /// Emits a sema error if the type conversion fails. | 28 | /// Emits a sema error if the type conversion fails. |
| 29 | /// `let x: i32 = 1` | 29 | /// `let x: i32 = 1` |
| 30 | as, | 30 | as, |