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

StringReader using io module private constants #20975

Closed
daddycocoaman opened this issue Mar 8, 2024 · 0 comments
Closed

StringReader using io module private constants #20975

daddycocoaman opened this issue Mar 8, 2024 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@daddycocoaman
Copy link
Contributor

daddycocoaman commented Mar 8, 2024

Describe the bug

Hi. I'm attempting to use the new string_reader module but it looks like it's trying to use private constants from io. Would it be a good idea to make those constants public?

Reproduction Steps

module main

import os
import io
import io.string_reader

pub fn file_magic(filename string) !string {
	file_data := os.open(filename)!
	mut reader := string_reader.StringReader.new(reader: file_data)
	magic := reader.read_string(3)!
	return magic
}

fn main() {
	println(file_magic("v.mod")!)
}

Expected Behavior

Read 3 bytes from the file (should output "Mod" in this example)

Current Behavior

C:/Users/daddycocoaman/dev/_langs/v/vlib/io/string_reader/string_reader.v:71:33: error: constant `io.read_all_len` is private
   69 |
   70 |     // make sure there is enough room in the string builder
   71 |     unsafe { r.builder.grow_len(io.read_all_len) }
      |                                    ~~~~~~~~~~~~
   72 |     defer {
   73 |         // shrink the length of the buffer to the total of bytes read
C:/Users/daddycocoaman/dev/_langs/v/vlib/io/string_reader/string_reader.v:87:35: error: constant `io.read_all_grow_len` is private
   85 |             break
   86 |         } else if r.builder.len == end {
   87 |             unsafe { r.builder.grow_len(io.read_all_grow_len) }
      |                                            ~~~~~~~~~~~~~~~~~
   88 |         }
   89 |     }
C:/Users/daddycocoaman/dev/_langs/v/vlib/io/string_reader/string_reader.v:109:12: error: constant `io.read_all_len` is private
  107 |     start := r.builder.len
  108 |     // make sure there is enough room in the string builder
  109 |     if n > io.read_all_len {
      |               ~~~~~~~~~~~~
  110 |         unsafe { r.builder.grow_len(io.read_all_len) }
  111 |     } else {
C:/Users/daddycocoaman/dev/_langs/v/vlib/io/string_reader/string_reader.v:110:34: error: constant `io.read_all_len` is private
  108 |     // make sure there is enough room in the string builder
  109 |     if n > io.read_all_len {
  110 |         unsafe { r.builder.grow_len(io.read_all_len) }
      |                                        ~~~~~~~~~~~~
  111 |     } else {
  112 |         unsafe { r.builder.grow_len(n) }
C:/Users/daddycocoaman/dev/_langs/v/vlib/io/string_reader/string_reader.v:126:20: error: constant `io.read_all_grow_len` is private
  124 |             break
  125 |         } else if r.builder.len == end {
  126 |             if n - end > io.read_all_grow_len {
      |                             ~~~~~~~~~~~~~~~~~
  127 |                 unsafe { r.builder.grow_len(io.read_all_grow_len) }
  128 |             } else {
C:/Users/daddycocoaman/dev/_langs/v/vlib/io/string_reader/string_reader.v:127:36: error: constant `io.read_all_grow_len` is private
  125 |         } else if r.builder.len == end {
  126 |             if n - end > io.read_all_grow_len {
  127 |                 unsafe { r.builder.grow_len(io.read_all_grow_len) }
      |                                                ~~~~~~~~~~~~~~~~~
  128 |             } else {
  129 |                 unsafe { r.builder.grow_len(n - end) }

Possible Solution

Make the read_all_len and read_all_grow_len constants public

Additional Information/Context

No response

V version

V 0.4.4 a867ed6

Environment details (OS name and version, etc.)

V full version: V 0.4.4 a867ed6
OS: windows, Microsoft Windows 11 Pro v26058 64-bit
Processor: 4 cpus, 64bit, little endian, 

getwd: C:\Users\daddycocoaman\dev\offensiv
vexe: C:\Users\daddycocoaman\dev\_langs\v\v.exe
vexe mtime: 2024-03-08 01:49:10

vroot: OK, value: C:\Users\daddycocoaman\dev\_langs\v
VMODULES: OK, value: C:\Users\daddycocoaman\.vmodules
VTMP: OK, value: C:\Users\daddycocoaman\AppData\Local\Temp\v_0

Git version: git version 2.42.0.windows.2
Git vroot status: weekly.2024.10-3-ga867ed6a-dirty
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 b99a453d

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@daddycocoaman daddycocoaman added the Bug This tag is applied to issues which reports bugs. label Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

1 participant