mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 14:21:09 +01:00
Start drafting out semantic type checking. (#2406)
This is a first pass at what semantic type checking might look like. Types propagate along nodes, we use an InvalidType object when there's an error, and once there's an InvalidType we stop doing so much type checking. This adds some RealLiteral handling in order to get type mismatches. I'm cautious about creating some real value for SemanticsIR (since the tokenized buffer version is a bit constrained), so I'm not doing that yet. But I will probably need to in order to maintain SemanticsIR having hermetic copies of its data, without a parse tree dependency.
This commit is contained in:
@@ -85,9 +85,9 @@ class TokenizedBuffer::Lexer {
|
||||
|
||||
Lexer(TokenizedBuffer& buffer, DiagnosticConsumer& consumer)
|
||||
: buffer_(&buffer),
|
||||
translator_(buffer, ¤t_column_),
|
||||
translator_(&buffer, ¤t_column_),
|
||||
emitter_(translator_, consumer),
|
||||
token_translator_(buffer, ¤t_column_),
|
||||
token_translator_(&buffer, ¤t_column_),
|
||||
token_emitter_(token_translator_, consumer),
|
||||
current_line_(buffer.AddLine({0, 0, 0})),
|
||||
current_line_info_(&buffer.GetLineInfo(current_line_)) {}
|
||||
@@ -944,7 +944,7 @@ auto TokenizedBuffer::TokenLocationTranslator::GetLocation(Token token)
|
||||
// Find the corresponding file location.
|
||||
// TODO: Should we somehow indicate in the diagnostic location if this token
|
||||
// is a recovery token that doesn't correspond to the original source?
|
||||
return SourceBufferLocationTranslator(*buffer_, last_line_lexed_to_column_)
|
||||
return SourceBufferLocationTranslator(buffer_, last_line_lexed_to_column_)
|
||||
.GetLocation(token_start);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user