From 18887de12f2f9718500ceb66cf8c14220db36650 Mon Sep 17 00:00:00 2001 From: r00ster Date: Wed, 19 Dec 2018 13:12:28 +0100 Subject: [PATCH 1/2] Fix typos --- src/array.cr | 2 +- src/compiler/crystal/codegen/codegen.cr | 2 +- src/compiler/crystal/compiler.cr | 4 ++-- src/compiler/crystal/macros.cr | 8 ++++---- src/compiler/crystal/program.cr | 16 ++++++++-------- src/compiler/crystal/semantic/call.cr | 2 +- .../crystal/semantic/cleanup_transformer.cr | 2 +- src/compiler/crystal/semantic/main_visitor.cr | 2 +- .../semantic/type_declaration_processor.cr | 2 +- src/compiler/crystal/syntax/lexer.cr | 2 +- .../crystal/tools/init/template/gitignore.ecr | 2 +- src/compiler/crystal/types.cr | 4 ++-- src/concurrent.cr | 4 ++-- src/concurrent/future.cr | 4 ++-- src/crystal/system/dir.cr | 2 +- src/crystal/system/win32/file.cr | 2 +- src/file.cr | 4 ++-- src/file/info.cr | 2 +- src/http/server.cr | 2 +- src/io.cr | 2 +- src/static_array.cr | 2 +- src/time.cr | 10 +++++----- src/time/location.cr | 2 +- src/tuple.cr | 4 ++-- 24 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/array.cr b/src/array.cr index b46d4027d62a..89f7e2ccb356 100644 --- a/src/array.cr +++ b/src/array.cr @@ -1547,7 +1547,7 @@ class Array(T) end # Modifies `self` by randomizing the order of elements in the collection - # using the given *random* number generator. Returns `self`. + # using the given *random* number generator. Returns `self`. def shuffle!(random = Random::DEFAULT) @buffer.shuffle!(size, random) self diff --git a/src/compiler/crystal/codegen/codegen.cr b/src/compiler/crystal/codegen/codegen.cr index 490abfe77978..b8b50fc50ee1 100644 --- a/src/compiler/crystal/codegen/codegen.cr +++ b/src/compiler/crystal/codegen/codegen.cr @@ -108,7 +108,7 @@ module Crystal # an "Reference**" llvm value and you need to load that value # to access it. # However, the "self" argument is not copied to a local variable: - # it's accessed from the arguments list, and it a "Reference*" + # it's accessed from the arguments list, and is a "Reference*" # llvm value, so in a way it's "already loaded". # This field is true if that's the case. getter already_loaded : Bool diff --git a/src/compiler/crystal/compiler.cr b/src/compiler/crystal/compiler.cr index 08f2f50cd30d..3b116fd2a3b7 100644 --- a/src/compiler/crystal/compiler.cr +++ b/src/compiler/crystal/compiler.cr @@ -20,7 +20,7 @@ module Crystal CC = ENV["CC"]? || "cc" CL = "cl" - # A source to the compiler: it's filename and source code. + # A source to the compiler: its filename and source code. record Source, filename : String, code : String @@ -83,7 +83,7 @@ module Crystal # one LLVM module is created for each type in a program. property? single_module = false - # Set to a `ProgressTracker` object which tracks compilation progress. + # A `ProgressTracker` object which tracks compilation progress. property progress_tracker = ProgressTracker.new # Target triple to use in the compilation. diff --git a/src/compiler/crystal/macros.cr b/src/compiler/crystal/macros.cr index d06e57b4d65d..9a81832155f6 100644 --- a/src/compiler/crystal/macros.cr +++ b/src/compiler/crystal/macros.cr @@ -70,7 +70,7 @@ module Crystal::Macros # Compiles and execute a Crystal program and returns its output # as a `MacroId`. # - # The file denote by *filename* must be a valid Crystal program. + # The file denoted by *filename* must be a valid Crystal program. # This macro invocation passes *args* to the program as regular # program arguments. The program must output a valid Crystal expression. # This output is the result of this macro invocation, as a `MacroId`. @@ -106,7 +106,7 @@ module Crystal::Macros # shell commands at compile time, or other macro run programs). It's also strongly # discouraged to have a macro run program take a lot of time, because this will # slow down compilation times. Reading files is OK, opening an HTTP connection - # at compile-time will most likely result if very slow compilations. + # at compile-time will most likely result in very slow compilations. def run(filename, *args) : MacroId end @@ -819,8 +819,8 @@ module Crystal::Macros def default_value : ASTNode end - # Returns whether this variable has a default value (which. - # can in turn be `nil`). + # Returns whether this variable has a default value + # (which can in turn be `nil`). def has_default_value? : BoolLiteral end diff --git a/src/compiler/crystal/program.cr b/src/compiler/crystal/program.cr index 140728508a92..30ee88fffc62 100644 --- a/src/compiler/crystal/program.cr +++ b/src/compiler/crystal/program.cr @@ -44,7 +44,7 @@ module Crystal # # The way we detect this is by remembering the type of the splat, # associated to a def's object id (the UInt64), and on an instantiation - # we compare the new type with the previous one and check if if contains + # we compare the new type with the previous one and check if it contains # the previous type. getter splat_expansions = {} of UInt64 => Type @@ -110,7 +110,7 @@ module Crystal # The main filename of this program property filename : String? - # Set to a `ProgressTracker` object which tracks compilation progress. + # A `ProgressTracker` object which tracks compilation progress. property progress_tracker = ProgressTracker.new def initialize @@ -204,7 +204,7 @@ module Crystal types["ARGC_UNSAFE"] = @argc = argc_unsafe = Const.new self, self, "ARGC_UNSAFE", Primitive.new("argc", int32) types["ARGV_UNSAFE"] = @argv = argv_unsafe = Const.new self, self, "ARGV_UNSAFE", Primitive.new("argv", pointer_of(pointer_of(uint8))) - # Make sure to initialize ARGC and ARGV as soon as the program starts + # Make sure to initialize ARGC_UNSAFE and ARGV_UNSAFE as soon as the program starts class_var_and_const_initializers << argc_unsafe class_var_and_const_initializers << argv_unsafe @@ -429,7 +429,7 @@ module Crystal end property recorded_requires = [] of RecordedRequire - # Rmembers that the program depends on this require. + # Remembers that the program depends on this require. def record_require(filename, relative_to) : Nil recorded_requires << RecordedRequire.new(filename, relative_to) end @@ -452,12 +452,12 @@ module Crystal end {% end %} - # Returns the `Nil` `Type` + # Returns the `Nil` type def nil_type @nil.not_nil! end - # Returns the `Hash` `Type` + # Returns the `Hash` type def hash_type @hash_type.not_nil! end @@ -496,12 +496,12 @@ module Crystal end end - # Retutns the `Struct` type + # Returns the `Struct` type def struct @struct_t.not_nil! end - # Retutns the `Class` type + # Returns the `Class` type def class_type @class.not_nil! end diff --git a/src/compiler/crystal/semantic/call.cr b/src/compiler/crystal/semantic/call.cr index e931cc2bb631..5bbbf645dd59 100644 --- a/src/compiler/crystal/semantic/call.cr +++ b/src/compiler/crystal/semantic/call.cr @@ -45,7 +45,7 @@ class Crystal::Call return recalculate_lib_call obj_type end - # Check if it's call inside LibFoo + # Check if its call is inside LibFoo # (can happen when assigning the call to a constant) if !obj && (lib_type = scope()).is_a?(LibType) return recalculate_lib_call lib_type diff --git a/src/compiler/crystal/semantic/cleanup_transformer.cr b/src/compiler/crystal/semantic/cleanup_transformer.cr index b6aa3e5417df..5d558729034b 100644 --- a/src/compiler/crystal/semantic/cleanup_transformer.cr +++ b/src/compiler/crystal/semantic/cleanup_transformer.cr @@ -572,7 +572,7 @@ module Crystal if replacement = node.syntax_replacement replacement.transform(self) else - # If it's `nil?` we want to give an error if obj has a Pointer type + # If it's `nil?`, we want to give an error if obj has a Pointer type # inside it. This is because `Pointer#nil?` would previously mean # "is it a null pointer?" but now it means "is it Nil?" which would # always give false. Having this as a silent change will break a lot diff --git a/src/compiler/crystal/semantic/main_visitor.cr b/src/compiler/crystal/semantic/main_visitor.cr index 8543a475705f..392d7b97d605 100644 --- a/src/compiler/crystal/semantic/main_visitor.cr +++ b/src/compiler/crystal/semantic/main_visitor.cr @@ -658,7 +658,7 @@ module Crystal if var.freeze_type deps = var.dependencies? - # If no dependencies it's the case of a global for a regex literal. + # If no dependencies, it's the case of a global for a regex literal. # If there are dependencies and it's just one, it's the same var deps ? deps.size == 1 : false else diff --git a/src/compiler/crystal/semantic/type_declaration_processor.cr b/src/compiler/crystal/semantic/type_declaration_processor.cr index c2c77b051aff..2a9a6cb0494f 100644 --- a/src/compiler/crystal/semantic/type_declaration_processor.cr +++ b/src/compiler/crystal/semantic/type_declaration_processor.cr @@ -211,7 +211,7 @@ struct Crystal::TypeDeclarationProcessor # Check if var is uninitialized var.uninitialized = true if info.uninitialized - # If the variable is gueseed to be nilable because it is not initialized + # If the variable is guessed to be nilable because it is not initialized # in all of the initialize methods, and the explicit type is not nilable, # give an error right now if check_nilable && instance_var && !var.type.includes_type?(@program.nil) diff --git a/src/compiler/crystal/syntax/lexer.cr b/src/compiler/crystal/syntax/lexer.cr index 2b6c32cc1fe6..694b3250260a 100644 --- a/src/compiler/crystal/syntax/lexer.cr +++ b/src/compiler/crystal/syntax/lexer.cr @@ -2278,7 +2278,7 @@ module Crystal end when '#' if delimiter_state - # If it's "#{..." we don't want "#{{{" to parse it as "# {{ {", but as "#{ {{" + # If it's "#{...", we don't want "#{{{" to parse it as "# {{ {", but as "#{ {{" # (macro expression inside a string interpolation) if peek_next_char == '{' char = next_char diff --git a/src/compiler/crystal/tools/init/template/gitignore.ecr b/src/compiler/crystal/tools/init/template/gitignore.ecr index be98ad03183f..0f841cfea7f4 100644 --- a/src/compiler/crystal/tools/init/template/gitignore.ecr +++ b/src/compiler/crystal/tools/init/template/gitignore.ecr @@ -6,6 +6,6 @@ <%- if config.skeleton_type == "lib" -%> # Libraries don't need dependency lock -# Dependencies will be locked in application that uses them +# Dependencies will be locked in applications that use them /shard.lock <%- end -%> diff --git a/src/compiler/crystal/types.cr b/src/compiler/crystal/types.cr index e32103c878c0..2296e32dfb57 100644 --- a/src/compiler/crystal/types.cr +++ b/src/compiler/crystal/types.cr @@ -583,7 +583,7 @@ module Crystal raise "BUG: #{self} doesn't implement add_subclass" end - # Replace type parameetrs in this type with the type parameters + # Replace type parameters in this type with the type parameters # of the given *instance* type. def replace_type_parameters(instance) : Type self @@ -694,7 +694,7 @@ module Crystal end # A type that has a name and can be inside a namespace. - # For example, given `class Foo::Bar`, `Foo` is the namespace and `Bar` is the name. + # For example, given `class Foo::Bar`, `Foo` is the namespace and `Bar` is the name. # # There are other types that have a name but it can be deduced from other(s) type(s), # so they don't inherit NamedType: a union type, a metaclass, etc. diff --git a/src/concurrent.cr b/src/concurrent.cr index 2b420c1ac923..374628c9a504 100644 --- a/src/concurrent.cr +++ b/src/concurrent.cr @@ -5,7 +5,7 @@ require "./concurrent/*" # Blocks the current fiber for the specified number of seconds. # -# While this fiber is waiting this time other ready-to-execute +# While this fiber is waiting this time, other ready-to-execute # fibers might start their execution. def sleep(seconds : Number) if seconds < 0 @@ -17,7 +17,7 @@ end # Blocks the current Fiber for the specified time span. # -# While this fiber is waiting this time other ready-to-execute +# While this fiber is waiting this time, other ready-to-execute # fibers might start their execution. def sleep(time : Time::Span) Crystal::Scheduler.sleep(time) diff --git a/src/concurrent/future.cr b/src/concurrent/future.cr index 0f0cfbcf74a7..b6c2c9ba553d 100644 --- a/src/concurrent/future.cr +++ b/src/concurrent/future.cr @@ -117,7 +117,7 @@ class Concurrent::Future(R) end # Spawns a `Fiber` to compute *&block* in the background after *delay* has elapsed. -# Access to get is synchronized between fibers. *&block* is only called once. +# Access to get is synchronized between fibers. *&block* is only called once. # May be canceled before *&block* is called by calling `cancel`. # ``` # d = delay(1) { Process.kill(Signal::KILL, Process.pid) } @@ -140,7 +140,7 @@ def future(&exp : -> _) end # Conditionally spawns a `Fiber` to run *&block* in the background. -# Access to get is synchronized between fibers. *&block* is only called once. +# Access to get is synchronized between fibers. *&block* is only called once. # *&block* doesn't run by default, only when `get` is called. # ``` # l = lazy { expensive_computation } diff --git a/src/crystal/system/dir.cr b/src/crystal/system/dir.cr index 558968ea5402..0d90406038e9 100644 --- a/src/crystal/system/dir.cr +++ b/src/crystal/system/dir.cr @@ -10,7 +10,7 @@ module Crystal::System::Dir # Rewinds the iterator to the beginning of the directory. # def self.rewind(handle : Handle) : Nil - # Closes *handle*, freeing it's resources. + # Closes *handle*, freeing its resources. # def self.close(handle : Handle) : Nil # Returns the current working directory of the application. diff --git a/src/crystal/system/win32/file.cr b/src/crystal/system/win32/file.cr index 511b8dec5016..39068b93ff90 100644 --- a/src/crystal/system/win32/file.cr +++ b/src/crystal/system/win32/file.cr @@ -67,7 +67,7 @@ module Crystal::System::File return check_not_found_error("GetFileAttributesEx") if ret == 0 if file_attributes.dwFileAttributes.bits_set? LibC::FILE_ATTRIBUTE_REPARSE_POINT - # Could be a symlink, retrieve it's reparse tag with FindFirstFile + # Could be a symlink, retrieve its reparse tag with FindFirstFile handle = LibC.FindFirstFileW(winpath, out find_data) return check_not_found_error("FindFirstFile") if handle == LibC::INVALID_HANDLE_VALUE diff --git a/src/file.cr b/src/file.cr index 23096a6fe5d2..f3827ee360f8 100644 --- a/src/file.cr +++ b/src/file.cr @@ -340,7 +340,7 @@ class File < IO::FileDescriptor current = bytes.size - 1 - # if the pattern is foo. it has no extension + # if the pattern is foo, it has no extension return "" if bytes[current] == '.'.ord # position the reader at the last . or SEPARATOR @@ -351,7 +351,7 @@ class File < IO::FileDescriptor current -= 1 end - # if we are the beginning of the string there is no extension + # if we are at the beginning of the string, there is no extension. # /foo or .foo have no extension return "" unless current > 0 diff --git a/src/file/info.cr b/src/file/info.cr index 0df61ab3fd05..b0517a06b440 100644 --- a/src/file/info.cr +++ b/src/file/info.cr @@ -31,7 +31,7 @@ class File # # The binary representation of this enum is defined to be same representation # as the permission bits of a unix `st_mode` field. `File::Permissions` - # can also be compared to it's underlying bitset, for example + # can also be compared to its underlying bitset, for example # `File::Permissions::All == 0o777` will always be `true`. # # On windows, only the `OwnerWrite` bit is effective. All file permissions diff --git a/src/http/server.cr b/src/http/server.cr index 11d50abf0afb..e49e78791818 100644 --- a/src/http/server.cr +++ b/src/http/server.cr @@ -101,7 +101,7 @@ class HTTP::Server # Returns `true` if this server is closed. getter? closed : Bool = false - # Returns `true` if this server is listening on it's sockets. + # Returns `true` if this server is listening on its sockets. getter? listening : Bool = false # Creates a new HTTP server with the given block as handler. diff --git a/src/io.cr b/src/io.cr index 3163fd445f18..0abef408f8f7 100644 --- a/src/io.cr +++ b/src/io.cr @@ -621,7 +621,7 @@ abstract class IO ascii = delimiter.ascii? decoder = decoder() - # # If the char's representation is a single byte and we have an encoding, + # If the char's representation is a single byte and we have an encoding, # search the delimiter in the buffer if ascii && decoder return decoder.gets(self, delimiter.ord.to_u8, limit: limit, chomp: chomp) diff --git a/src/static_array.cr b/src/static_array.cr index 98328956c16f..cf52d8124179 100644 --- a/src/static_array.cr +++ b/src/static_array.cr @@ -174,7 +174,7 @@ struct StaticArray(T, N) end # Modifies `self` by randomizing the order of elements in the array - # using the given *random* number generator. Returns `self`. + # using the given *random* number generator. Returns `self`. # # ``` # a = StaticArray(Int32, 3).new { |i| i + 1 } # => StaticArray[1, 2, 3] diff --git a/src/time.cr b/src/time.cr index 94a4db674b49..22a4e7acb258 100644 --- a/src/time.cr +++ b/src/time.cr @@ -785,7 +785,7 @@ struct Time end # Creates an instance specified by a commercial week date consisting of ISO - # calendar *year* and *week* and a *day_of_week`. + # calendar *year*, *week* and a *day_of_week*. # # This equates to the results from `#calendar_week` and `#day_of_week`. # @@ -796,7 +796,7 @@ struct Time # * `day_of_week`: `1..7` def self.week_date(year : Int32, week : Int32, day_of_week : Int32 | DayOfWeek, hour : Int32 = 0, minute : Int32 = 0, second : Int32 = 0, *, nanosecond : Int32 = 0, location : Location = Location.local) : self # For this calculation we need to know the weekday of Januar 4. - # The number of the day plus a fixed offset of 4 gives a correction valud + # The number of the day plus a fixed offset of 4 gives a correction value # for this year. jan4_day_of_week = Time.utc(year, 1, 4).day_of_week correction = jan4_day_of_week.to_i + 4 @@ -877,7 +877,7 @@ struct Time # Returns `true` if `#location` equals to the local time zone # (`Time::Location.local`). # - # Since the system's settings may change during a programm's runtime, + # Since the system's settings may change during a program's runtime, # the result may not be identical between different invocations. def local? : Bool location.local? @@ -889,7 +889,7 @@ struct Time # date-time representation (wall clock) would compare differently. # # To ensure the comparison is also true for local wall clock, both date-times - # need to be transforemd to the same time zone. + # need to be transformed to the same time zone. def <=>(other : Time) : Int32 cmp = total_seconds <=> other.total_seconds cmp = nanosecond <=> other.nanosecond if cmp == 0 @@ -1132,7 +1132,7 @@ struct Time end # Parses a `Time` from *time* string using the given *pattern* and - # `Time::Location.local` asdefault location + # `Time::Location.local` as default location # # See `Time::Format` for details. # diff --git a/src/time/location.cr b/src/time/location.cr index a1b4c7e6df9a..efe9043694b6 100644 --- a/src/time/location.cr +++ b/src/time/location.cr @@ -40,7 +40,7 @@ require "./location/loader" # The local time zone can be accessed as `Time::Location.local`. # # It is initially configured according to system environment settings, -# but it's value can be changed: +# but its value can be changed: # # ``` # location = Time::Location.local diff --git a/src/tuple.cr b/src/tuple.cr index 839dc159dab1..2a48760cd6a7 100644 --- a/src/tuple.cr +++ b/src/tuple.cr @@ -66,10 +66,10 @@ struct Tuple include Indexable(Union(*T)) include Comparable(Tuple) - # Creates a tuple that will contain the given arguments. + # Creates a tuple that will contain the given values. # # This method is useful in macros and generic code because with it you can - # creates empty tuples, something that you can't do with a tuple literal. + # create empty tuples, something that you can't do with a tuple literal. # # ``` # Tuple.new(1, "hello", 'x') #=> {1, "hello", 'x'} From 425f5c0522cd57b4a8ceaae5e1fb8d36a40968a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Mon, 31 Dec 2018 10:39:04 +0100 Subject: [PATCH 2/2] Surround ARGC_UNSAFE and ARGV_UNSAFE by ` Co-Authored-By: r00ster91 <35064754+r00ster91@users.noreply.github.com> --- src/compiler/crystal/program.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/crystal/program.cr b/src/compiler/crystal/program.cr index 30ee88fffc62..7916694b9861 100644 --- a/src/compiler/crystal/program.cr +++ b/src/compiler/crystal/program.cr @@ -204,7 +204,7 @@ module Crystal types["ARGC_UNSAFE"] = @argc = argc_unsafe = Const.new self, self, "ARGC_UNSAFE", Primitive.new("argc", int32) types["ARGV_UNSAFE"] = @argv = argv_unsafe = Const.new self, self, "ARGV_UNSAFE", Primitive.new("argv", pointer_of(pointer_of(uint8))) - # Make sure to initialize ARGC_UNSAFE and ARGV_UNSAFE as soon as the program starts + # Make sure to initialize `ARGC_UNSAFE` and `ARGV_UNSAFE` as soon as the program starts class_var_and_const_initializers << argc_unsafe class_var_and_const_initializers << argv_unsafe