Comments (4)
I just meant that macros generating invalid UTF-8 shouldn't result in a "compiler bug" message because it's user error.
from crystal.
Oh, and this "you've found a bug in the Crystal compiler" message should probably also be fixed.
What fixing does it need?
from crystal.
Note the same error appears when the first byte of the source file is invalid UTF-8 encoding.
$ echo '\xFF' | bin/crystal eval
Using compiled compiler at .build/crystal
Regex match error: UTF-8 error: illegal byte (0xfe or 0xff) (ArgumentError)
from src/regex/pcre2.cr:275:9 in 'match_data'
from src/regex/pcre2.cr:207:18 in 'match_impl'
from src/regex.cr:672:12 in 'match_at_byte_index'
from src/regex.cr:621:12 in 'match:options'
from src/string.cr:3227:13 in '=~'
from src/compiler/crystal/semantic/suggestions.cr:41:25 in 'lookup_similar_def'
from src/compiler/crystal/semantic/suggestions.cr:73:7 in 'lookup_similar_def_name'
from src/compiler/crystal/semantic/call_error.cr:594:5 in 'raise_undefined_method'
from src/compiler/crystal/semantic/call_error.cr:98:7 in 'raise_matches_not_found'
from src/compiler/crystal/semantic/call.cr:291:9 in 'lookup_matches_in_type'
from src/compiler/crystal/semantic/call.cr:254:3 in 'lookup_matches_in_type:search_in_parents:with_autocast'
from src/compiler/crystal/semantic/call.cr:210:5 in 'lookup_matches_in'
from src/compiler/crystal/semantic/call.cr:209:3 in 'lookup_matches_in:with_autocast'
from src/compiler/crystal/semantic/call.cr:197:7 in 'lookup_matches_without_splat'
from src/compiler/crystal/semantic/call.cr:124:17 in 'lookup_matches:with_autocast'
from src/compiler/crystal/semantic/call.cr:113:5 in 'lookup_matches'
from src/compiler/crystal/semantic/call.cr:90:15 in 'recalculate'
from src/compiler/crystal/semantic/main_visitor.cr:1380:7 in 'recalculate_call'
from src/compiler/crystal/semantic/main_visitor.cr:1359:7 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/semantic/main_visitor.cr:688:11 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/semantic/main_visitor.cr:6:7 in 'visit_main:process_finished_hooks:cleanup:visitor'
from src/compiler/crystal/progress_tracker.cr:22:7 in 'semantic:cleanup'
from src/compiler/crystal/compiler.cr:219:14 in 'compile:combine_rpath'
from src/compiler/crystal/compiler.cr:213:56 in 'compile:combine_rpath'
from src/compiler/crystal/command/eval.cr:29:5 in 'eval'
from src/compiler/crystal/command.cr:101:7 in 'run'
from src/compiler/crystal/command.cr:55:5 in 'run'
from src/compiler/crystal/command.cr:54:3 in 'run'
from src/compiler/crystal.cr:11:1 in '__crystal_main'
from src/crystal/main.cr:129:5 in 'main_user_code'
from src/crystal/main.cr:115:7 in 'main'
from src/crystal/main.cr:141:3 in 'main'
from /lib/x86_64-linux-gnu/libc.so.6 in '??'
from /lib/x86_64-linux-gnu/libc.so.6 in '__libc_start_main'
from /home/johannes/src/crystal-lang/crystal/.build/crystal in '_start'
from ???
Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues
It's very peculiar that the compiler advances as far as into a regex match to look for similar names until it notices something is wrong.
If an invalid encoding is in any later byte, the compiler errors gracefully:
$ echo '-\xFF' | crystal eval
Error: file 'eval' is not a valid Crystal source file: Unexpected byte 0xff at position 1, malformed UTF-8
from crystal.
The expected error is only raised inside Crystal::Lexer#next_char_no_column_increment
after a call to Char::Reader#next_char
; this needs to be done in Crystal::Lexer#initialize
as well
from crystal.
Related Issues (20)
- Fail to compile in path with whitespace HOT 3
- Compiler error when output directory for object file is missing HOT 3
- It's impossible to create a regex that is MULTILINE but not DOT_ALL HOT 2
- Error: read before assignment to local variable '' HOT 2
- `Enumerable` method to find the first truthy block result and return that result HOT 8
- Macro Code Coverage
- `MacroIf` then/else missing location information HOT 1
- Doc error for Channel#close, Channel#close? when channel is buffered channel.
- Invalid memory access in release mode with LLVM 18 HOT 2
- `Number.new` causes `IndexError` with blank value and `whitespace: false`
- Ensuring `class_getter` runs exactly once under concurrent access HOT 3
- Methods with a return type of `self` automatically return `self` HOT 3
- Store annotations within the node they annotate HOT 3
- Method overloads and type specificity are influenced by order of definition HOT 5
- Error: undefined method 'to_unsafe' for Foo (compile-time type is MyModule) HOT 4
- Filters do not work with dependencies tool on Windows HOT 1
- Zstd - "you've found a bug in the Crystal compiler. Please open an issue .. " HOT 2
- `XML::Error.errors` leaks memory HOT 16
- Nil assertion failed (NilAssertionError) HOT 2
- Setting instance variable of file-private type in def parameter breaks with restriction augmenter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crystal.