Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exercises: stubs: resolve unused parameter errors #195

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

ee7
Copy link
Member

@ee7 ee7 commented Mar 1, 2023

Before this commit, when testing an unchanged exercise stub:

$ zig test test_leap.zig
leap.zig:1:19: error: unused function parameter
pub fn isLeapYear(year: u32) bool {
                  ^~~~

With this commit:

$ zig test test_leap.zig
Test [1/9] test.year not divisible by 4 in common year... thread 123456 panic: please implement the isLeapYear function
/foo/exercism-tracks/zig/exercises/practice/leap/leap.zig:3:5: 0x201234 in isLeapYear (test)
    @panic("please implement the isLeapYear function");
[...]

Closes: #175


Refs: #143

With this PR, there are no more unused parameter errors when running zig fmt . --ast-check. This gets us closer to checking stubs in CI.

$ zig fmt . --ast-check
./exercises/practice/binary-search/binary_search.zig:3:60: error: use of undeclared identifier 'SearchError'
pub fn binarySearch(target: usize, buffer: ?[]const usize) SearchError!usize {
                                                           ^~~~~~~~~~~
./exercises/practice/grains/grains.zig:1:29: error: use of undeclared identifier 'ChessboardError'
pub fn square(index: isize) ChessboardError!u64 {
                            ^~~~~~~~~~~~~~~
./exercises/practice/hamming/hamming.zig:1:55: error: use of undeclared identifier 'DnaError'
pub fn compute(first: []const u8, second: []const u8) DnaError!usize {
                                                      ^~~~~~~~
./exercises/practice/proverb/proverb.zig:1:26: error: use of undeclared identifier 'mem'
pub fn recite(allocator: mem.Allocator, words: []const []const u8) (fmt.AllocPrintError || mem.Allocator.Error)![][]u8 {
                         ^~~
./exercises/practice/resistor-color-duo/resistor_color_duo.zig:1:34: error: use of undeclared identifier 'ColorBand'
pub fn colorCode(colors: []const ColorBand) anyerror!isize {
                                 ^~~~~~~~~
./exercises/practice/resistor-color/resistor_color.zig:1:25: error: use of undeclared identifier 'ColorBand'
pub fn colorCode(color: ColorBand) isize {
                        ^~~~~~~~~
./exercises/practice/resistor-color/resistor_color.zig:5:25: error: use of undeclared identifier 'ColorBand'
pub fn colors() []const ColorBand {
                        ^~~~~~~~~
./exercises/practice/rna-transcription/rna_transcription.zig:3:25: error: use of undeclared identifier 'mem'
pub fn toRna(allocator: mem.Allocator, dna: []const u8) (RnaError || mem.Allocator.Error)![]const u8 {
                        ^~~
./exercises/practice/secret-handshake/secret_handshake.zig:1:38: error: use of undeclared identifier 'mem'
pub fn calculateHandshake(allocator: mem.Allocator, number: isize) mem.Allocator.Error![]const Signal {
                                     ^~~
./exercises/practice/space-age/space_age.zig:12:58: error: use of undeclared identifier 'Planet'
    fn getOrbitalPeriodInSecondsFromEarthYearsOf(planet: Planet) f64 {
                                                         ^~~~~~
./exercises/practice/space-age/space_age.zig:17:47: error: use of undeclared identifier 'Planet'
    fn getOrbitalPeriodInEarthYearsOf(planet: Planet) f64 {
                                              ^~~~~~
./exercises/practice/triangle/triangle.zig:4:54: error: use of undeclared identifier 'TriangleError'
    pub fn init(first: f64, second: f64, third: f64) TriangleError!Triangle {
                                                     ^~~~~~~~~~~~~
./exercises/practice/triangle/triangle.zig:11:79: error: use of undeclared identifier 'TriangleError'
    fn verifyIfDegenerateAttributesExist(first: f64, second: f64, third: f64) TriangleError!void {
                                                                              ^~~~~~~~~~~~~
./exercises/practice/triangle/triangle.zig:18:77: error: use of undeclared identifier 'TriangleError'
    fn verifyIfTriangleInequalityHolds(first: f64, second: f64, third: f64) TriangleError!void {
                                                                            ^~~~~~~~~~~~~

@ee7 ee7 requested a review from ErikSchierboom March 1, 2023 12:12
Before this commit, when testing an unchanged exercise stub:

    $ zig test test_leap.zig
    leap.zig:1:19: error: unused function parameter
    pub fn isLeapYear(year: u32) bool {
                      ^~~~

With this commit:

    $ zig test test_leap.zig
    Test [1/9] test.year not divisible by 4 in common year... thread 123456 panic: please implement the isLeapYear function
    /foo/exercism-tracks/zig/exercises/practice/leap/leap.zig:3:5: 0x201234 in isLeapYear (test)
        @Panic("please implement the isLeapYear function");
    [...]

Closes: exercism#175
@ee7 ee7 force-pushed the exercises-stubs-unused-parameters branch from 49c8900 to a92fd4b Compare March 2, 2023 21:41
@ee7 ee7 merged commit 39194db into exercism:main Mar 2, 2023
@ee7 ee7 deleted the exercises-stubs-unused-parameters branch March 2, 2023 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stubs: consider resolving unused parameter errors
2 participants