morpho icon indicating copy to clipboard operation
morpho copied to clipboard

[Bug] Segfault upon incorrect assginment in function call

Open joshichaitanya3 opened this issue 2 years ago • 2 comments

Describe the bug A typo in the constructor for FloryHuggins results in a segfault

To Reproduce

var m = Mesh("tetrahedron.mesh") // Can be found under test/functionals/floryhuggins

var mref = m.clone()

var lfh = FloryHuggins(mref. // This "." should be a ","
    a = 1.0,
    b = 1.0,
    c = 1.0,
    phi0=0.5
)

print lfh

Expected behavior Some error indicating that the period is incorrect

joshichaitanya3 avatar Mar 04 '22 21:03 joshichaitanya3

This segfaults in program_bindobject in vm/vim.c:100 obj it in invalid pointer We should probably catch this as a parse error before this happens as mref. is not valid.

ConduitDan avatar Mar 29 '22 14:03 ConduitDan

Assignment in fn call

ConduitDan avatar Mar 29 '22 15:03 ConduitDan

Fixed by #276 (and possibly earlier).

  • The supplied program now generates "Expression expected" error.
  • Added a test class/syntax_error_in_constructor.morpho to check this works correctly.

Thankyou @ConduitDan for this report; apologies it took a long time to be fixed by the new parser in the 0.6 series.

softmattertheory avatar Oct 24 '24 14:10 softmattertheory