Skip to content

iteration functions with missing typed function logic #3390

@dvd101x

Description

@dvd101x

Found an issue in iteration functions like map and forEach, when a callback function has only one signature only its signature is mapped, but the signature doesn't have the logic to reject and covert types.

const fn = math.typed({number: x => x + 1})
math.map([1, 2], fn) // yields [2, 3]
math.map([1, 'text'], fn) // yields [2, 'text1']
// should be TypeError: Function map cannot apply callback arguments to function : Cannot convert "text" to a number

The issue was introduced by #3256

It should be possible to still use the signature only for matrices that have a datatype that is not "mixed" or undefined

I'm willing to work on the fix, might have an effect on performance but have more precise results.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions