require 'hashmap'
require 'string'
local map: hashmap(integer, record{word: string, reading: string})
local row: record{id: string, word: string, reading: string}
local id = tonumber(row.id)
map[row] = { -- oops! should be: map[id]
word = row.word,
reading = row.reading,
}
With output:
hasherrormsg.nelua:1:1: from: AST node Block
require 'hashmap'
^~~~~~~~~~~~~~~~~
error: in call of function 'hashmap(int64, V).__atindex' at argument 1: no viable type conversion from 'record{id: string, word: string, reading: string}' to 'int64'
Expected behavior
An error message pointing to the map[row], similar to
require 'hashmap'
require 'string'
local map: hashmap(integer, record{word: string, reading: string})
local row: record{id: string, word: string, reading: string}
local function set(k: #[map.type.K]#, v: #[map.type.V]#) map[k] = v end
local id = tonumber(row.id)
set(row, { -- oops! should be: map[id]
word = row.word,
reading = row.reading,
})
Which has this output:
hasherrormsg2.nelua:1:1: from: AST node Block
require 'hashmap'
^~~~~~~~~~~~~~~~~
hasherrormsg2.nelua:9:4: error: in call of function 'set' at argument 1: no viable type conversion from 'record{id: string, word: string, reading: string}' to 'int64'
set(row, { -- oops! should be: map[id]
^~~~~~~
Code example
With output:
Expected behavior
An error message pointing to the
map[row]
, similar toWhich has this output:
Environment
Linux x86_64 Nelua 0.2.0-dev Build number: 1605 Git date: 2023-11-05 16:12:59 -0300 Git hash: decf713ca4bfd99b7bb9ae3c5f66b87761fd8621 Semantic version: 0.2.0-dev.1605+decf713c Copyright (C) 2019-2023 Eduardo Bart (https://nelua.io/)